I'm not quite sure what you're trying to do here.
Up vote 0 down vote favorite share g+ share fb share tw.
From a tableview to another table view (using Xcode 4.2 and iOS 5). FirstPage. H #import "FavoritesController.
H" #import "Profiles. H" -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { FavoritesController * favoriteview = FavoritesController alloc init; favoriteview setTitle:@"Favorites"; NSMutableArray * profiles = NSMutableArray allocinit ; profiles = NSMutableArray arrayWithCapacity:20; Profiles * profile = Profiles allocinit; profile. Profile_name = @"Woot"; profile.
Biz_type_desc = @"Woot 1"; profile. Profile_address = @"123, woot"; profile. Profile_email = @"[email protected]"; profiles addObject:profile; profile=Profiles allocinit; profile.
Profile_name = @"Jin-Aurora"; profile. Biz_type_desc = @"Software"; profile. Profile_address = @"682A"; profile.
Profile_email = @"jin@jin. Biz"; profiles addObject:profile; self. NavigationController pushViewController:favoriteview animated:YES; favoriteview.
Profilelist = profiles; } FavoriesController. H @interface FavoritesController : UITableViewController @property(nonatomic,strong)NSMutableArray * profilelist; @end FavoriteController. M #import "FavoritesController.
H" #import "Profiles. H" #import "ProfileCell. H" -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.
Profilelist count; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"ProfileCell"; ProfileCell *cell = (ProfileCell *)tableView dequeueReusableCellWithIdentifier:CellIdentifier; Profiles * profile = self. Profilelist objectAtIndex:indexPath. Row; cell.nameLabel.
Text = profile. Profile_name; cell.biztypeLabel. Text = profile.
Biz_type_desc; // Configure the cell... return cell; } Storyboard Table View Picture of prototype cell xib with Identity inspector Picture of prototype cell xib with Attributes inspector This is the error I got 2012-02-08 22:28:37.719 test4668:f803 Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:' ios uitableview uistoryboard link|improve this question edited Feb 8 at 14:58Anna Karenina16.3k22128 asked Feb 8 at 14:36Jin-Aurora33.
I'm not quite sure what you're trying to do here: NSMutableArray * profiles = NSMutableArray allocinit ; profiles = NSMutableArray arrayWithCapacity:20; The first line creates a new mutable array called profiles. The second line creates an autoreleased mutable array with capacity 20 and assigns it to profiles. So you're basically covering up the array you created in the first line.
You can either say NSMutableArray *profiles = NSMutableArray alloc initWithCapacity:20; or NSMutableArray *profiles = NSMutableArray arrayWithCapacity:20; The reason you're crashing, as mentioned by @wattson12 is that you are dequeueing a cell that hasn't been created. You always want to try and dequeue a cell, but if one doesn't exist, you need to create one. Again, @wattson12 has provided the necessary code for that task.
My code is like this. ProfileCell *cell = (ProfileCell *)tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = ProfileCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier; } but nothing show on table :( – Jin-Aurora Feb 9 at 1:48 If you're not getting any cells, set a breakpoint in that method and see if it even gets hit. If not, the usual culprit is that your datasource is saying there aren't any rows in that section (see what the numberOfRowsInSection method returns).
– jmstone Feb 9 at 2:28 hi jmstone, it returns me tableViewCellStyleDefault due to I put in initWithStyle, I set cell.textLabel. Text = profile. Profile_name.
It able to show. But I wan to show the custom table cell :( What should I put in InitWithStyle for my custom table view cell? – Jin-Aurora Feb 9 at 3:29 When you say custom table cell, are you loading the cell from a nib?
– jmstone Feb 9 at 14:34 how to load in correct way? Thanks for your reply :) – Jin-Aurora Feb 9 at 16:47.
Your cellForRowAtIndexPath method attempts to dequeue a reusable cell, but doesn't create it if it is not found (which will happen if there are no cells available to reuse) ProfileCell *cell = (ProfileCell *)tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (!cell) cell = ProfileCell alloc initWithStyle:style reusueIdentifier:CellIdenfitier autorelease.
My code is like this. ProfileCell *cell = (ProfileCell *)tableView dequeueReusableCellWithIdentifier:CellIdentifier; if (cell == nil) { cell = ProfileCell alloc initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier; } but nothing displayed on the table, by the way how you define style? – Jin-Aurora Feb 9 at 1:29 that looks ok, check to make sure that method is being called, maybe self.
ProfileList count is returning 0. Style is defined in the UITableView docs – wattson12 Feb 9 at 9:42 hi wattson, I put UITableCellStyleDefault, and it shown me default table cell. I missed out something so that custom table cell unable to show.
Any way can help? :( – Jin-Aurora Feb 9 at 11:29 if you are using a custom table view cell and setting up your views in init/layout subviews then it doesn't matter what style you put, just use default. I don't use interface builder so not sure if the way you have set up your cell is right – wattson12 Feb 9 at 11:31 I customize my table cell on storyboard, change the identifier to "ProfileCell", create a UITableViewCell named as "ProfileCell" and replace the class of table cell.
I don't know where am I miss out. Besides this way, how to do it without using interface builder? Please advice :) – Jin-Aurora Feb 9 at 16:54.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.