I have made a UITabelView that works nice, but when i now press a link I would like it to go to a new View, which should be different depending on the link choosen. How can i do that? If there is a nice tutorial it whould be nice.
Thanks for the help.
Implement UITableViewDelegate's method - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath and there display a picture.
Related
I'm curious about the best way to build the view to show user comments similar to Instagram.
http://imgur.com/lDSRAPs
My best guess is that its a table view which loads each user comments from the backend. If so, how can I add the "click to more comments" functionality?
Yep, you are right, you can use the scheme like this:
Of course you should correctly set:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
to return needed cell.
And when user clicks on More Comments button, just flag this, remove this row, and add new comment rows.
I am using https://github.com/John-Lluch/SWRevealViewController to develop my apps. I have two questions while I building my apps.
In the SidebarViewController.m, which is came from the tutorial here http://www.appcoda.com/ios-programming-sidebar-navigation-menu/,
I edited the method
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
where I want to disable specific menu button on specific view by setting cell.userInteractionEnabled property, for example when I'm in the vc1, I disable the segue that will persent vc1. By this mean, I want to find out the current viewcontroller's restorationIdentifier in order to decide the selection, but I can't find any method to get the current viewController showing, I've try
self.revealViewController.frontViewController.presentedViewController.restorationIdentifier self.revealViewController.frontViewController.childViewControllers objectAtIndex:
which is all wrong.
2.Besides the segue function to change view, my apps support manually change view, suppose I press some button on vc1, the apps will push vc2. By this mean, the SidebarViewController.m method,
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
wont call again, so that the setting previously wont apply to the new vc2. I tried [tableview reload] , but still dont work.
Thanks for everyone's great help.
I don't know if this will help you but I use this code to localise my sliding menu if language settings are changed (my localisation is inside the App):
Inside SWRevealViewController.m.
- (void (^)(void))_rearViewDeploymentForNewFrontViewPosition:(FrontViewPosition)newPosition
...
if ([_rearViewController isKindOfClass:([tvcMenu class])])
{
[((tvcMenu*)_rearViewController).tvMenu reloadData];
}
return completion;
I'm trying to make a list like Pinterest using UICollectionView that has cell animation similar to Google Plus's list.
For UITableView, I can do cell animation in this call back
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{}
But UICollectionViewDelegate have no such the callback.
Any idea?
Nearly all of the animation you'll want to do should be handled by your UICollectionViewLayout subclass. UICollectionViews are pretty awesome, and can probably handle what you want to do very nicely.
Describe the animation you want to do, add an image, or show the code. I'm too lazy to go download apps to answer questions.
I have created a UITableView populated by data coming from mysql (using NSJSONSERIALIZATION). Now the problem is one thing. What I retrieved was the product name. I want to have an accessory view (arrow like on the right side of cell). once clicked, new view and load details of that product there.
I know it can be done, but don't know how or where to look for a good tutorial. Any recommendations?
am really new to iOS development.
thanks a lot
Use this tableview delegate.
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
...and in cellForRowAtIndexPath: add this.
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
I'm trying to create a button set up exactly like this:
How would I do this? Can someone show me the code? Is there a way to "Group" UIButtons like this?
You'll want to use a UITableViewController with the sections set to be UITableViewStyleGrouped.
Each of the groups is a section, so you'll want to return how many sections you have with - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView.
For every section, you want to specify how many rows there are with - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section.
You'll want to customize each cell with - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath (which, by the way, tells you which section's particular row you're modifying in the indexPath variable).
Finally, you'll want to handle the row click in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath, using the pattern XCode provides for you:
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
Hope this helps!
That's a one-group UITableView with two rows (cells). The table style is UITableViewStyleGrouped. I'd recommend responding to selection of the cell using the delegate's –tableView:didSelectRowAtIndexPath: method as opposed to using UIButtons within the cell -- much nicer visual effect.
You can't group uibuttons like that. You can achieve this look-and-feel several ways, the most elegant is to use the grouped style uitableview.
However if you would want your buttons only to look like this, but not exactly like this, then you could also specify images for you buttons. Uglier way to do it, however much simpler ...