Select the first element in view for Voice Over - swift

I am using Xcode to make an iOS app. When I segue into the next view controller, it has objects in the following order from top to bottom on the screen: label, collection view, button. When I use voiceover, I want the first item on the screen to be in focus (the label). However, whatever I do, it is always a particular cell from the collection view that is selected by default (somewhere in the middle of the screen). In landscape it is a different cell and in portrait a different cell. But every time it is that same cell. I tried using UIAccessibilityPostNotification, as well as using delays and other things. Nothing seems to work.

Should be posted when a new view appears that encompasses a major portion of the screen.
Optionally, pass the element that VoiceOver should move to after processing the notification.
UIKIT_EXTERN UIAccessibilityNotifications
UIAccessibilityScreenChangedNotification;
You need to provide
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, youLabel);

Related

Swift - UIButton as overlay on UIScrollView

I have a scroll view which contains different ui components such as text fields, labels etc.
The scroll view takes almost the full size of the screen. Logically separated, I want to add/display a button which is not a part of the content of the scroll view.
This leads to the problem that my button doesn't react on my touches. In case, I reduce the size of the scroll view so that the frames don't interfere with the ones from the button, everything works as expected.
I tried to bring the button to the front (view.bringSubviewToFront(infoButton)) but it still doesn't work.
I think you want to implement something like 'Gmail app, a plus button is floating at the bottom right of the screen.
add your scroll view to view and add other elements to scroll view:
view.addSubview(yourScrollView)
yourScrollView.addSubview(yourButton)
yourScrollView.addSubview(yourLabel)
after you finished adding scrollView's sub views it's time to add your button to -> View (not scroll view)
and everything should work fine as you expected
Issue is solved!
It is a matter of how you ad your sub views to the main view. In my case, I added the info button first to the main view followed by adding the scroll view to the main view.
You need to change the order. First you add the scroll view to the main view and then the button.

How to build this screen in iOS?

I'm new to iOS development and am trying to build something like the screen below:
If I was doing it in Android, I can easily build the above UI in a few minutes. However, I don't know how to go about it with iOS.
I understand that the whole ViewController can be embedded in a navigation controller, which produces the title bar above. What about the bottom part though? I'm thinking of using something like a grouped UITableView but I'm not sure, since every cell will have very different contents:
A search bar, perhaps a subclassed UISearchBar, which I also don't know how to customize--the Search button at the right is required but isn't in the default UISearchBar. When the user taps on it, the UISearchBar must be translated to the navigation bar, no need to display a UITableView of suggested results. I don't know how to do that, too.
A button that, when tapped, flies in a modal from the bottom (I imagine it to be another ViewController with a grouped UITableView), to allow the user to choose from defined locations. Once selected, the modal closes and the button text is replaced with the selected location. This sounds much easier to do.
A header ("Item categories") and the list of categories, which may change in number. If the parent isn't a grouped UITableView, I think this part can be a UILabel and a non-scrolling UITableView with a height that changes depending on how many cells it has. If there are plenty table cells that don't fit given the screen's height, everything below the navigation bar can be scrolled vertically. That, I also don't know how to do.
If anyone can just guide me to what native iOS components I can use to build the above screen, and maybe a couple of tutorials to the things I just said I don't know how to do, I'd appreciate it.
You said it right .All the basic info you need is with you.
To build a searchbar like that i dont think you have to subclass it.
Bottom comprises of tableview.
Actually these Questions are seperately available in SO itself.So search seperately for your needs and you can achieve whatever you want
One basic principle : You cant achive anything by just thinking.Trying and get to it and if you have any issues look forward at it.All the issues will have an answer on the way.
Lots of components you need there.. Search Bar, UIPickerView and UITableView. I would like to give you some pointers.
1) You can refer http://www.appcoda.com/how-to-add-search-bar-uitableview/ for Search bar
2) When clicking on the Button, you can bring up a UIPickerView instead of another controller. For that you can refer http://www.techotopia.com/index.php/An_iOS_5_iPhone_UIPickerView_Example
3) You can use a normal Tableview with a single section, configure the section header to display Item categories.
You are asking too much to ask how to do every component of your UI. I will just answer a little.
Yes, a grouped table view is a good design. I am using a grouped table view for varying types of input. I have an actual table, with rows that can be added, and deleted, and contain an editable text area. Then I have three groups that only really show one piece of content each: two are sliders and one is a switch.
For choosing the location, pushing another view controller on your navigation stack would be the more typical way to handle it. You will save some effort that way, with some buttons and behaviors built in, but a modal view controller is not much harder. I'm not sure if you can make a navigation view fly in vertically, but does your app have to be frame-for-frame identical to the android version?

Display UITableView's section title when index is touched

I'm writing a dictionary app to study iOS and I've implemented a UITableView with the alphabet as section titles and an index of all the letters on the right side. It works perfectly, but is it possible for me to display the selected index in a box at the center of the screen? I'm looking at the UITableViewDelegate reference but can't see any methods I might override. Help?
You'd have to manually create a UIView that you put above the UITableView which then shows the letter or whatever you want to present. Make sure not to add it to the table view itself as it's a UIScrollView subclass and your view would be affected by its contentOffset.
When the user presses one index or moves his finger above it, this callback gets called:
-tableView:sectionForSectionIndexTitle:title atIndex:
Use it to change your view's contents and make it visible and set a timer for it to fade out again.
You have to create custom view that display when you click on the cell and in that view you can add Label to show the alphabet which you have selected.
And yes also if you want to display it on center of your screen than give its X and Y coordinates value according to it.hope it helps...

How can I animate this custom view transition in my iPhone app?

This is a tricky question to explain, but basically I have an app with a home screen with a bunch of circular icons on it. When the user taps on an icon, it pushes a table view onto the navigation stack. When an icon is tapped on the home screen, I want the tapped icon to stay on top of the table view as it scrolls in, and then drop onto the table view in the cell that represents it. All the other icons, however, should stay below the incoming table view, like normal. Here's a quick diagram I whipped up...
I'm about to begin researching this, I just wanted to quickly post this question in case anyone has some ideas about how I can approach this. Thanks so much for your wisdom!
Oh thats soo easy!!!
I'll try to explain my solution:
You need two sets of icons.
One set lays on Home View, second is exact location, but as a subview on main window (by default - hidden)
Once You select a button, and want to push a list - You un-hide corresponding window subview icon, and with delay - animate / shrink it to tableView corresponding location.
Once animation is finished - hide icon (instant hide will not be noticeable, as this icon will be positioned/scaled to precisely reassemble icon in tableview), and move it to default position/scale (still hidden).
That's it.
This is pretty simple, and can be done without adding second instances of your buttons. You'll use the view hierarchies z-index for this.
When you add the table view as a subview of the main view don't use addSubview, use:
[self.view insertSubview:table belowSubview:button];
Button^ will represent the button that you want to stay on top, and for your other buttons, you just have to make sure that they are lower on the stack. This way, when the table flies in, it can keep going past the button but the button will stay above it.
You can also use:
[self.view insertSubview:table atIndex:5];
On all of these buttons and the table to have total control over each objects z-index.

Image Slider to my iPhone application

I need this kind of component to my iPhone Application. How could I Added to this to my project.
after i click that black color I need to animated it to left side and show next one.. like that
Try a tableView with one row and one section. Then the action of clicking on the row can trigger the delegate method of the tableView and use that to do whatever you like.
Alternately, you can make this a button with a custom view and swap out the view each time the user taps it.