I am doing the project which need to use the storyboard to rewrite the old project. I got some problems when I doing it use the storyboard. I use the normal view controller instead of tableview controller, because there are some buttons and labels in this view controller. The problem is I don't know how to link between this view controller and the detail view controller when users select the cell from the table view.
Select a cell in the Table View. And make a segue to the DetailViewController
by ctrl clicking on the Table Cell and dragging to the DetailViewController
in the Storyboard. Then select a segue type based on the type of transition you want: modal, or push (if these view controllers are embedded in a navigation controller, etc.)
可能您应该使用以下代码:
[self.navigationController pushViewController:[YourNewViewControllerClass new] animated:YES];
simply drag the tableview to a normal VC.
ctrl+drag from your table to the orange circle below to connect as delegate/datasource.
make your VC to implement uitableview delegate and datasource protocols ( @interface MyVC : UIViewController <UITableViewDataSource, UITableViewDelegate>
).
write the mandatory protocol methods:
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.