UIScrollView multiple page confusion - ios

So I have an existing app I'm working on for a friend...
and let's say I double click on animals_real and I get this screen...
Basically all I want to do is create a back button back to the home page on the animals_real page and all the other ones like it(body_parts_real, cleaning_real, etc.) but for whatever reason I can't find the xib file or the code for it and I'm not entirely sure what file it would be in. Also, since I am fairly new I'm not entirely sure how to implement the back button. Any help is greatly appreciated.
----------------------------------EDIT 1------------------------------------------
The main page works under ViewControllerForIphone.xib and the settings page is under SettingViewControllerIphone.xib. This led me to believe that the other pages would be under the SubPECSViewController_iPhone.xib. However, if I go in and edit that it doesn't change anything when I run the simulator. So, basically I have been trying to understand UIScrollView better and how it works but I am kind of just stuck.

Welcome to iOS. Other commenters will point out that you should start here at the UICollectionViewDelegate Reference (which you can also get to through Xcode (shift+command+0)
Basically, a uicollection view populates itself based on some array of data.Look here to see what's going on
(void)insertItemsAtIndexPaths:(NSArray *)indexPaths
When you tap on animals, this method is called:
– collectionView:didSelectItemAtIndexPath:
Some logic happens here, and I'm presuming you load the collectionview from yet another array.
To solve your original problem of a "back button," you might simply want to reload the viewcontroller's original datasource or possibly "pop" back up the navigation stack. Again, without seeing at least part of the code, there's very little we can do except speculate :)

Related

How to write to a sidebar menu from another view

I have an app where there is a sidebar menu. Like the Instagram and Facebook apps, I have a user settings view, where I can upload a picture. This picture is also shown in the sidebar menu. This picture is loaded once, when the sidebar menu tickers viewdidload.
The problem is if the user changes the image in the user settings view, I can't get it to update the sidebar menu. The viewdidload runs only once.
The best thing would be if i could set the UIimage in the sidebar from the user settings view - but is this even possible?
I not that good at Xcode (swift) yet so bear with me.
Without code samples or knowing the implementation of your sidebar these are just guesses. viewDidLoad is only called once when the view is added to the hierarchy. Try moving logic that needs to execute on each subsequent appearance to viewWillAppear.
In the past when I've implemented a sidebar, I've used a UITableView or UICollectionView. This simplified determining what was selected and reloading the state/data of the view as you're using well defined delegates and methods. This worked well for me but YMMV.
The best thing would be if i could set the UIimage in the sidebar from the user settings view - but is this even possible?
It is probably best to keep your sidebar and settings view separate. They don't need to know that the other exists. This doesn't mean they shouldn't share the same data or an abstraction (service class, plist, etc) over that data.
You have several possibilites to get this done. A non exhausting list:
NSNotificationCenter
Key Value Observing
Delegation
Make your menuVC a delegate for the viewController where your profile-image-change action can be performed. When someone changes the profile-image, call:
delegate.profileImageDidChange()
In your delegate protocol, you have to define that method of course. Please see the tutorial on Delegation (Hyperlink). If you need more help with implementing it into your code, just ask another question or edit your question.

UIPageViewController goes to wrong controller when using UIPageViewControllerTransitionStyleScroll

This other case seems to describe a similar behavior, but the accepted solution did not change anything in my application:
UIPageViewController navigates to wrong page with Scroll transition style
One of the functions of my app is to offer random flashcards from a large list of vocabulary words. Going forward is OK, but after reaching the end, something strange happens. I go backwards, and the correct controller is displayed, but the same controller is presented again when going backwards the next time. Then everything proceeds as normal. But always the double presentation of one of the controllers after reaching the end and then going backwards.
If I change the transition style to UIPageViewControllerTransitionStylePageCurl, the wrong behavior disappears. But page curl doesn't make sense in my application.
I'll post my code if you guys think it would be helpful, but based on the other post, and on the fact that it works OK using page curl style, this seems to be a bug in iOS with the scroll style that must be somehow compensated for.
Thanks for any help.
The viewWillAppear method of the controllers added to the page view controller is the key to figuring out what the correct page is in a timely fashion. I had the viewWillAppear to report the key number that was originally passed to it (that allowed for data lookup) back to the controller that contains the page view controller, which was also the datasource. Then it searches the datasource array for that object and when it finds it, the correct index is established.
If you use setViewControllers to go to a new controller, you need to set the animated to NO for UIPageViewControllerTransitionStyleScroll.

When I transfer from my master view to my detail view after adding a new item, my detail view is empty

I'm making a sample app to learn iOS dev, and I have the app create default items to populate the tableview originally, and you can add further ones as well.
If I tap on the default ones (well, there's only one) and segue to the detail view it shows all the details (Name, Location and Date) as intended. But if I add a new one, it comes up with those fields being Empty.
I can't figure out why. I have seemingly all the view refreshing methods set, and it should be setting the detail view's data object which then feeds the labels.
Could anyone help? I'd supply further code if requested, I just don't know what to supply now as I'm not sure exactly where the problem is. It's a rather simple app, though.
Project available here: http://cl.ly/3N0o272M3y1K
Ok this took a bit longer than planned - but it is a good way to learn.
I have attached the project in a zip file.
The code is a bit different then what you posted, but if you compare them side by side, you will see how they are planned and build differently.
It shows the Segue working within the Storyboard.
There where 2 big problems with your project outside of your misuses of the methods.
You need something like Core Data if you want your data to be persistant. In the example I have given you I have used Plist, this will do the trick, but is not persistant in this case.
Also your detailViewController had no labels for the text to appear, so you will need to look into Custom Cells for that - to match your design.
Good Luck and I hope this is useful:-)
Updated Project

iOS: UI Ideas for moving items between multi-level tableViews

I am building an iOS app that allows the user to browse a tableView, click a cell, then navigate deeper into another tableView using a navigationController.
I have a requirement to be able to move any of those items/cells to another place in the navigation stack. Right now my idea is, once the user selects the cells to move, to display a modal tableView that will allow the user to navigate through the same structure as before, but this time choose the location (by pressing and holding) to place those cells.
Are there any other UI ideas or clever programatic ideas that anyone might have that could be a better solution to this problem?
Perhaps take a look at how Apple's iOS Mail moves email messages between different mailboxes?
This also basically displays a modal view controller, but it flattens the hierarchy, by indenting nested items below their parent objects. You than just select the item that is the destination.
This of course only works if your hierarchy is not too deep, otherwise it's probably best to do it like you outlined it. The only thing I would perhaps recommend doing in addition, is to also have some sort of visual method (button?) to select the destination. A long press by itself might not be intuitive enough.

UINavigationController with in UITabBarNavigationController doesn't load the table data

Im extremely new to IOS.
I have a UITabBarNavigationController inside it I have an UINavigationController
I have a problem, The UINavigationController Doesn't load the table values (as in i have put all the methods and stuff for the datasource and mapped it in IB but it still doesn't seem to work)
For code click here
PS : When you run the project it will ask you for a username and a password please enter user1 for both.
Thanks for your help.
There's really a lot of stuff I would notify you about, man. But to be closer to your very question (I explored only the first tab, the others should be resolved in a similar way):
You have warnings in the interface builder. Maybe in the code in some cases you can ignore them, but not in IB. I corrected it and (not just after that) it worked (leave your email in comment if you want me send it to you). But I would advise you to spend 20 mins on watching
this video.
The code which initializes your tableView works before the user is even logged in (so that it's being initialized with nothing), therefore, even if all the rest of code is working, you will see the items in your tableView only after you reinitialize your tableView (e.g. change the tab and go back to your first one "Appointment" tab).
In the class AppointmentTable move your code from viewDidLoad to viewWillAppear or viewDidAppear (the last ones work every time you show your tab on the screen).
P.S. Leave your email in comment so I could send you corrected (not fully of course, but only in the places I pointed out) version of your project.

Resources