XCode Change Image From PopOver Navigation - xcode

I'm wondering if you can help me.
Basically we have a set of 16 images,
ImageA.png
ImageB.png ect ect...
That need to be shown by selecting it from a "Menu".
I want it to work like a split view controller, but I don't want to limit the width of the screen by having the navigation bar at the side, as the app must run in Landscape mode.
Here is the screenshots of what I have come up with instead of the SplitView;
http://i.stack.imgur.com/fdy21.png
The image is in a UIImageView,
And I have added a PopOver to the button that is linked to the UITableView.
What I want, is to be able to select an image from the PopOver Navigation, and it will change the image in the UIImageView to the corresponding.
Sorry if I haven't explained myself enough... I'm new to XCode!
Also: I am using XCode in Storyboard mode;
http://i.stack.imgur.com/RSuyY.png
Thanks,
Alex

To make the master view not be static on the side, implement this method in your UISplitViewControllerDelegate:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
return YES from this method, and the split view controller will behave the same way in landscape as it does in portrait

Related

How to show different views in same window in cocoa?

Is it possible to do navigation within the same window in a mac application ?(Like it is possible in ios apps).I want to show each view in the same window instead of opening different windows on a button click.
e.g When a user clicks a button then the next page should be loaded in the same window.(The next page will have nothing in common with the current page.)
You may use Tab View for easy switching between views on a same window.
UPDATE:
You may also customize your tab view , make it tabless (In the attributes inspector set style to tabless) and use your buttons to switch between views.
You may take help from the following link : http://devcry.heiho.net/2012/01/nstabview-tutorial.html
OR
You may add or remove subviews from your window on button clicks, using
[[yourWindow contentView] addSubview: yourSubview]; // Add subview to window
[yourSubview removeFromSuperview]; //Remove subview
UPDATE:
Steps to swap between views using a tabless tab view.
Drag a NSTabView to your xib.
Set the no. of tabs in attribute inspector to no. of views you want.
Design each view of the tab as per your requirement.
Now in the attribute inspector of tabview, set style to tabless.
Now drag the buttons you want to use for swapping between views. Suppose Button0 and Button1 are for 1st and 2nd view of your tab view.
Create a IBOutlet for your NSTabView in your .h file. Bind it to the referencing outlet of you tabview.
IBOutLet NSTabView* tabview;
Set a IBAction for both your buttons in your .h class file.
In the button action method for button1, use
- (IBAction)button1clicked:(id)sender
{
[tab selectTabViewItemAtIndex:0];
}
Similarly in button2 action method use:
[tab selectTabViewItemAtIndex:1];
In this way you can have any no. of views and you may select any view on button click using
[tab selectTabViewItemAtIndex:(index of the view you want to load)];
In general you want to google for view swapping.
There are tons of examples out there. Some from Apple and lots elsewhere.
Much of it is very similar to iOS.
You need to read the docs a bit too.
Understand NSView and how to load views from nibs, how to create view objects in code, how to add a subview and how to remove a view.
There are many approaches to having different views for different reasons. The right approach is a combination of style, experience and what your app actually needs to do.
Cocoa includes NSBox, NSTabView, and lots of others. Those two can be configured to not display any visual indication that they are containers.
You will also need to understand at least a little about NSWindow to understand its content view (the root container of other views generally)

Xcode tableview hidden behind navigation bar

Can anyone please tell me how to fix the following issue.
I am building an iPhone app using Storyboard. I have a Navigation Controller as root view and off that a view controller. On this I have a few buttons that when clicked takes you to a table view controller. All fine and well, but when I link the buttons to their respective table views, the top navigation bar obscures the top cell in the table view controller.
Does anyone know why this is happening and how I can fix it?
Also it seems to have thrown off my layouts from the view controller from which they inherit.
See attached image for a better explanation perhaps.
I believe this is the intended behavior when using the translucent navigation bar. It's semi transparent specifically so that you can see items pass behind it (e.g. a table scrolling). If you don't want this, changing the navigation bar's style to opaque should solve the problem.
Since I wanted to keep the translucence, I just added a UIView between the navigation controller and the prototype cell (width of the view, height 60). That way the first cell in the table starts beneath the navigation bar but I can still see the scrolling underneath.
This is a bug/feature in IB when you use a translucent navigation bar, the content view runs under the navigation bar. For non transparent bars the content view begins after the bar. If your content view is a UIScrollView (UITableView is a descendent of UIScrollView) the content will be automatically scrolled so as to not be hidden under the navigation bar. So the problem only exist in IB when you run the app everything should be ok.
You just need go to the Navigation Controller properties, then Simulated Metrics, and change the Top Bar to be a Transluscent Navigation Bar WITH PROMPT. And that should be it. No need for that extra UIView

How can I get a two-row toolbar like in Mail.app and Xcode?

I'm trying to add a "second row" after my NSToolbar in my app, that remains part of the title bar. As an example, Mail has a thin gray divider line below the NSToolbar with some extras items below that. Very specifically, when the window is put into fullscreen mode, that second "row" stays attached to the title bar as it slides down under the system menu bar. Xcode has a similar story.
I tried setting my NSWindow to textured and placing my second row controls directly in the content view of the window. While this mostly looks correct in windowed mode, those controls of course won't appear attached to the toolbar when it slides down in fullscreen mode. So how can I achieve the same behavior that Mail and Xcode do? I've looked at a lot of toolbar customization code but none of them really cover this specific case.
fullScreenAccessoryView is deprecated in macOS 10.10
In order to do this in recent versions of macOS, use the addTitlebarAccessoryViewController method on your NSWindow and pass in a subclass of NSTitlebarAccessoryViewController.
For example:
NSTitlebarAccessoryViewController *accessoryViewController = [[NSStoryboard storyboardWithName:#"Main" bundle:nil] instantiateControllerWithIdentifier:#"AccessoryViewController"];
[self.mainWindowController.window addTitlebarAccessoryViewController:accessoryViewController];
What I needed to do was call [NSToolbar setFullScreenAccessoryView:] on the view below my toolbar. This results in the behavior I was aiming for. See the NSToolbar documentation for this method.
First one is normal toolbar. For second toolbar you can create a separate view of your desired height and add it in the main landing-window.

How to temporarily disable UIView background image from responding to mouse clicks in Interface Builder?

I have a UIView background image that I want to use for my view.
Now, on top of this image, I want to have buttons and position them relative to what I see in the image.
The problem is, these buttons were already added to the view before the background image was added. So now when I put the background image, entire view is background image and I am unable to access the buttons underneath it in Xcode.
Is there a way to tell Xcode that I am not interested in the UIView but actually the buttons that appear underneath it?
Check - (void)sendSubviewToBack:(UIView *)view in UIView
Would be something like
[self.view sendSubviewToBack:backgroundImageView];

detect scroll in horizontally uitableviewCell

I have UiTableView containing some data, and I want to scroll the UiTableViewCells horizontally to the left or right to show some UiButtons that act some action relatif to the content of the cell.
How Can I do this?
I'm thinking in creating custom cell, and putting a scrollView in it, May this did the trick?
There is a tutorial for this at http://idevrecipes.com/2011/04/14/how-does-the-twitter-iphone-app-implement-side-swiping-on-a-table/ with sample code. He is using a UISwipeGestureRecognizer to trigger an animation that pushes the cell off the screen.
You could use a swipe gesture recognizer attached to your cell.
You can add a UIScrollView to the contentView of a UITableViewCell. If you want to scroll the content using buttons, simply overlay the UIScrollView with buttons and make them call the various scrolling methods of UIScrollView.
Nested UIScrollView (UITableView inherits from UIScrollView) are quite clever about detecting touch conflicts and resolving the users intended gesture.
https://github.com/JonasGessner/JGScrollableTableViewCell might be what you're looking for. It implements this using a UIScrollView inside the cell (just like the iOS 7 mail app).
(Yes the answer is a bit late, but it's never too late! :P)

Resources