Uitableview 有没有可能将.xib窗口添加到选项卡式故事板

Uitableview 有没有可能将.xib窗口添加到选项卡式故事板,uitableview,xcode4.2,storyboard,uipickerview,xib,Uitableview,Xcode4.2,Storyboard,Uipickerview,Xib,我没有很长时间做代码,Xcode所以我有点垃圾基本上我已经创建了一个.xib并希望它出现在故事板中,但我真的没有胶水可以从哪里开始,因为我有一个xib窗口,其中有UITableView和UIPickerView,所有的代码在xib中都很好,但是我需要在故事板中添加代码吗如果不可能,我如何为我的应用程序创建某种下拉菜单。这是xib中的代码 #import <UIKit/UIKit.h> @interface myview : UIViewController <UITa

我没有很长时间做代码,Xcode所以我有点垃圾基本上我已经创建了一个.xib并希望它出现在故事板中,但我真的没有胶水可以从哪里开始,因为我有一个xib窗口,其中有
UITableView
UIPickerView
,所有的代码在xib中都很好,但是我需要在故事板中添加代码吗如果不可能,我如何为我的应用程序创建某种下拉菜单。这是xib中的代码

#import <UIKit/UIKit.h>

    @interface myview : UIViewController <UITableViewDelegate, UITableViewDataSource, UIPickerViewDelegate, UIPickerViewDataSource>    


    @property (strong, nonatomic) IBOutlet UITableView* tableView;
    @property (strong, nonatomic) IBOutlet UIPickerView* pickerView;
    @property (strong, nonatomic) NSMutableArray* tableData;
    @property (strong, nonatomic) NSMutableArray* pickerData;


    @end
我希望这一切都是有意义的,我期待着收到你的来信


非常感谢您的时间:)

没有下拉菜单自动转换。该过程是手动的,如下所述:

  • 从xib剪切并粘贴到新的序列图像板视图控制器(打开xib,选择全部并选择复制,然后转到序列图像板并将其粘贴到空的视图控制器)
  • 将新的视图控制器子类(.m和.h)添加到项目中
  • 将自定义方法从旧的视图控制器子类剪切并粘贴到新的视图控制器子类。小心不要迁移加载xib的代码
  • 首先将新的自定义视图控制器子类与序列图像板中的视图控制器相关联
  • 把所有的IBActions和iBaOutlet连接起来,你就可以出发了
  • 或者,您可以寻找使用segues而不是iActions的方法

  • 很抱歉,我确实尝试上传了一些图片,但我不会让我知道,我真的很感谢您的帮助,但我似乎不明白这一点,我不是Xcode的最佳人选。您是否有机会添加一些代码和逐步图片或其他内容:)对于基本内容,我建议。转到“iOS 5教程”部分。嗨,呃,我对故事板有点了解,现在只是xib文件还不知道如何进入故事板buddy@Paulmasters,打开xib,选择全部并选择复制,然后转到情节提要并将其粘贴到空视图控制器中。返回Ray Wenderlich。他在故事板第1部分介绍了这一点。
        #import "myview.h"
    
        @implementation myview
    
    
        @synthesize tableView, pickerView, tableData, pickerData;
    
    
    
    
    
        - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
        {
            self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
            if (self) {
                // Custom initialization
            }
            return self;
        }
    
    this is the -(void)viewDidLoad];etc..
    
    
        - (void)viewDidUnload
        {
            [super viewDidUnload];
    
            tableView.delegate = self;
            tableView.dataSource = self;
            pickerView.delegate = self;
            pickerView.dataSource = self;
    
            tableData = [[NSMutableArray alloc] init]; // table starts empty
            pickerData = [[NSMutableArray alloc] initWithObjects:@"1", @"2", @"3", @"4", @"5", nil]; // picker starts with values 1, 2, 3, 4, 5
    
            [tableView reloadData];
            [pickerView reloadAllComponents];    // Release any retained subviews of the main view.
            // e.g. self.myOutlet = nil;
        }
    
    -(bool) 
    
    
            - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
            {
                // Return YES for supported orientations
                return (interfaceOrientation == UIInterfaceOrientationPortrait);
            }
    
    
            - (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
                //The number of sections in UITableView
                return 1;
    
            }
    
    
            - (NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section {
                // The number of rows in the UITableView
                return [tableData count];
    
            }
    
    
             - (UITableViewCell*)tableView:(UITableView*)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath {
                    static NSString *cellIdentifier = @"cell";
    
               UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:cellIdentifier];
    
                    if (cell == nil) {
                        cell = [ [UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
    
              }
        cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
    
            return cell;
    
        }  
    
    
            - (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
                // Whatever happens when you select a table view row.
            }
    
            - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
            {
                // The number of sections in the UIPickerView
                return 1;
            }
    
            - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
            {
                // The number of rows in the UIPickerView
                return [pickerData count];
            }
    
            - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
            {
                // The data for each row in the UIPickerView
                return [pickerData objectAtIndex:row];
            }
    
            - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
            {
                // whatever you want to happen when a row is selected.
    
                // here I am assuming you want to remove from the picker and add to the table on selection
                [tableData addObject:[pickerData objectAtIndex:row]];
                [pickerData removeObjectAtIndex:row];
    
                [tableView reloadData];
                [self.pickerView reloadAllComponents];   
         }
    
    
    
    
            @end