I have a UIViewController that is embedded in a navigation controller. The navigation controller has a switcher with 2 items on it.
First item shows a UICollectionView with images, and the second UICollectionview needs to show an Image with some description text.
I have assigned the delegates in the ViewController for these two UICollectionViews to self.When the Viewloads, the first UICollectionView shows all the images. When I click on the second switcher item, none of the delegate methods like numberOfItemsInSection, cellForItemAtIndexPath gets triggered.
In viewDidLoad I hide the second UICollectionView and when the user hits the second switcher, I hide the first UICollectionView and unhide the second UICollectionView.
I cant figure out what is the issue. I tried using a [self.secondCV setNeedsDisplay] to trigger a redraw, but that dosent seem to work as well.
Anyone who has tried doing something similar or can explain what I might be doing wrong here ?
Thanks,
Abhishek
Related
I have this code linked to a button on a ViewController with a UITableView as subview:
-(IBAction)Action:(id)sender{
[tableView setContentSize:CGSizeMake(320, 1000)];
}
This makes tha tableView scrollable to the bottom so that I can use a couple of buttons I programatically added to the bottom. So far so good.
However, I want the tableView to be ok from the beginning, so I added the code inside viewDidLoad. Surprisingly, it doesn't work at all.
Could somebody give me a hand?
thanks!
If your datasource methods are being fired after viewDidLoad, the tableView content size will be reset when it's loaded. You'll need to make sure you've called reloadData for the table before the code above. If you're using a UITableViewController, the order the methods are called is:
viewDidLoad
ViewWillAppear:
<your datasource methods>
ViewDidAppear:
However, if you want buttons at the end of table, you should put them in the tableFooterView. You can do this in interface builder easily by dragging a view to the bottom of the tableView. Or you can do it in code (in your viewDidLoad method, for example)
Per #Justin's answer... your question isn't very clear
I'm not sure what your trying to accomplish. If your trying to access button on the bottom of a tableView why not use a Tableview Footer.
And if your trying to just scroll to the bottom of the tableview there is a method for that as well.
Need more info
I have a situation here which I am trying to resolve, but it seams I am missing something.
My architecture of the application is as following:
AppDelegate (TabBarController)
Navigation Controller
Viewcontroller one
Viewcontroller two
Viewcontroller three
Viewcontroller
Since I have lot of text validations and scrolling enabled, I am using a custom uiscrollview for viewcontroller one, two and three. In the custom uiscollview I am utilizing the code from Apple which causes scrollview to scroll if the textfield is being hidden behind the keyboard. The problem which I am occuring at this point is that I have the viewcontroller one working fine, but when it comes to viewcontroller two and three, it does see's that custom view controller after debugging, and reaches the point of "setContentOffSet" but not animating the scrollview, but just displaying the keyboard.
If anyone had this issue before, I would like to see what might I be missing here?
Using Storyboard I want to transition from UITableViewController to another ViewController on the click of Detail Disclosure button. I created a proper segue, but the transition does not happen when I run the application. Creating a segue from UIButton to a ViewController works properly. I tried embedding Navigation Controller in UITableViewController, it did not help.
Look forward to somebody helping me with this, as I have already spent four days on it.
Thanks!
Here's the most complete example I have found. Most have fallen short by not providing an example of how to go from the list of records to the detail of the selected records.
http://developer.apple.com/library/ios/#samplecode/SimpleDrillDown/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007416-Intro-DontLinkElementID_2
and here's the link to part 2 of the above tutorial:
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2
It should work without any code on your side
Ctrl click the prototype cell (table cell) and drag it to connect with the detail view. This will pop up a segue window. I chose Push since I have a navigation controller - but you can use Modal as well.
Note the segue name should show "Segue from UITableViewCell to ).
I've put in the disclosure icon on the Table cell as well.
I have a navigation controller that works with two UITableViewControllers. The first UITableViewController shows the user a list of their picture libraries, and when they tap a cell, the second UITableViewController gets pushed on the stack and displays the pictures in the library (much like a UIImagePicker). What I want to do is, when a user selects a photo library on the initial UITableViewController, I want the navigation title to not animate, while the transition of UITableViews does animate. Is there a way to accomplish this, or do I need to implement a UIViewController that swaps in two UITableViews (upon then I'm not sure if I'd be able to edit the back button after the second UITableView gets swapped in?).
I'm pretty sure that the easiest way would be to add two UITableViews into a UINavigationController's view and just animate them with [UIView beginAnimation] in a didselectrowatindexpath. You should also have a flag to save a view state - either a library picker view is shown to user or an image picker. Then you'll be able to handle this properly in a back button selector.
That's the easiest way IMO.
I'd recommend one UIViewController and animating the frames of the table views to transition between them.
I have a UIViewController, and within that view i have UITableView added in IB
The UITableView displays the items from my array beautifully
I would like to be able to edit the items i.e delete them
BUT The UITableView does not have a navigation bar, and i am not using a navigation controller within this app i am just adding and removing views manually.
What i would like to do is place an "edit" button somewhere else within the view ... is this possible? and how might i go about this?
Put a button somewhere. In an action connected to it set TableView's editing property to YES - it should work fine. You also need to implement delegate's editingStyleForRowAtIndexPath method (return UITableViewCellEditingStyleDelete to allow to delete cells).
You could make one special cell (e.g. 1st row, 1st group) a button by implementing a adaequate didSelectRowAtIndexPath.
Or you could put buttons for editing/deleting in each cell (if single deletion/editing makes sense).
Or you could place the UIIableView on a super view wich also contains the button(s) as sub views.