I am using this style of table view UITableViewCellStyleValue2.
I set editing, but I cant seem to get the arrows to show up on the right of the cell - like the Contacts app.
Also in the contacts app I notice that if I have a Favorite it puts a * (star) to the right. Any info on how to get an image would be appreciated.
Thanks!
You don't get the arrow on the right hand side by setting the editing - this is to set what happens if you click on an "edit" button at the top (eg drag & drop etc). What you're describing (from the reference to the Contacts app) is called a Disclosure indicator.
To get the arrow in the cell, put this in your tableView:cellForRowAtIndexPath method:
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
There are other type of cell accessories - as you're typing the above in, stop before the "DisclosureIndicator" bit and press [esc] to see the choices.
Now, your second requirement - the star - is a bit more involved. This is because the framework doesn't come with the star image as a standard accessory.
Therefore you need to build an image, push it as a view onto the cell, and then set it to be its accessory view (or you could set its specific coordinates if you wanted). You'll have to make (or find) an image from somewhere else to use as the star.
Assuming you have an image called "myStar.png" the code (in the same method as above) would be:
UIImage *myImage = [UIImage imageNamed:#"myStar.png"];
[cell addSubview:myImage];
cell.accessoryView = myImage;
Like I said, that last line is optional - you could always set the specific co-ordinates of the image on the cell yourself.
Hope that helps!
You probably wanted the cell.editingAccessoryType property. This defines the style of arrow when in editing mode, and it should work fine.
Related
I have two UIButtons that I added to my view
[self.view addSubview:button1];
[self.view addSubview:button2];
These buttons have a selector and in the selector is a menu where the user can choose an option and this option can vary in string size for the button so I decided to remove the buttons from the view and reload them again with different string size and button size. I have am getting the information from an API call so there is where I set the buttons up to my view. I tried to do this:
[button1 removeFromSuperview];
Also tried:
[self.button1 removeFromSuperView];
Now, for the UILabel I have it inside a table view cell because the string is long and covers my detailTextLabel. I am using UITableViewCellStyleValue1 for the cells. I have tried to use NSLineBreakByWordWrapping and set the numberOfLines to 0 as well as 5 so I then decided to add the UILabel inside the table view cell so I can control how far the string goes and I can also wrap that around. Since the cell was writing over and over the label every time the cell with the table view was hidden, I decided to create the label inside the if(cell == nil) statement.Like the button, this label also gets refreshed when the buttons are pressed and a menu option is chosen so I have to remove it from the view, the same way i did the buttons. For some reason it isn't working. Anyone have any thoughts/ideas/suggestions?
I also NSLog(#"%#",[button1 superview]) after I removed it to make sure that the button was indeed (null) as well as the label, and they do show up on the terminal as null but the buttons overlap each other, in fact you can still click the old button and you can see it underneath the new button. Same goes with the label. If you need any code let me know, this problem is frustrating me so much!
Also, I am on iOS7 and for some reason my device isn't displaying the status bar. I've tried to change it inside the info.plist -> status bar style. I've tried the 3 options it has but none of them seem to work. I checked all my xib files and checked for any hidden keywords in my .m files. Thanks in advance.
Since you mentioned the button was making an API call I am guessing you may be threading that section of code. If that's the case then the reason its not working is likely because you are not allowed to update the UI in a background thread.
Try replacing:
[button1 removeFromSuperview];
with this:
[button1 performSelectorOnMainThread:#selector(removeFromSuperview) withObject:nil waitUntilDone:NO];
I deeply suggest using storyboards, they make working with the UI a lot easier! They also allow you to play with constraints to see how your UI elements react to longer text or to the screen rotating, etc...
That apple tutorial:
https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/SecondiOSAppTutorial/Introduction/Introduction.html
goes through a simple app with storyboards!
I need to design a view that look like some thing like this. I know this a UITableView below the top bar. but how i can create a arrow like shown in attach image.
Any guide will be helpful
Thanks
It's not about "Creating Arrow" above UITableView, it's about "Showing White Triangle" in the Image. Also , Changing the Image of UIButton is more Simpler.
Change this Image
with
It seems to be header view of table.
Use this methode
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 40)];
//create your view here. buttons lable image etc.
return view;
}
There can be different ways to implement this but a much easier way is to use this library SDSegmentedControl
Hope this helps.
You can create custom header view instead of giving the background view to all the table . add the background image to the header view with array pointing in the opposite direction .
just use an arrow image in uiimageview, as it is only above the uitableview.
If the arrow will move to other label for ex, series or title, then just change the frame of that arrow imageview(u can also use uiviewanimations). This is what I had done when I had the same issue.
If you're going to be changing the rest of the view depending on what button the arrow is on, you also might want to look into putting your UITableViewController inside of a UITabBarController. You won't be able to get the same colorscheme as you have in your screenshot I don't believe, but a lot of the behind-the-scenes work for changing the rest of the view depending on what is selected will be done for you (or will at least be much easier to set up). Also, Apple seems to tend to grumble about "non-standard interfaces" when you try to make up your own way of doing something that already can be done with the built-in UI framework.
Could somebody explain how this app (FoodSpotting), creates their custom section header? It has a translucent black background, image of the user, and some nice text (loaded up from a server no doubt). My 2 big questions here are:
1. How does the app get the nice black translucency on the section header?
2. How do they get that little triangle arrow attached to the header?
I can pretty much figure out everything else based on using a custom view for the section header.
The Section header is a UIView just like any other. You can create it as beautiful, as complex, or as elaboarate as you like, using Interface Builder if you want, etc. Your table delegate's tableView:viewForheaderInSection is responsible for returning it, just like it is for other cell rows.
As to the little triangle: yeah, this threw us for a bit (we wanted something similar in our app) until we discovered that you can overlap the view with the row by "lying" about it's height: ie tableView:heightForHeaderInSection: returns a value slight less than it actually is. May not be the "right" way, but worked very nicely for us. Like this:
So the header is actually a perfect rectangle, mostly see-through at the bottom, with a small triangle "peeking" out:
Tell iOS that the header is 80px high, like this:
- (CGFloat) tableView:(UITableView *) tableView
heightForHeaderInSection:(NSInteger) section {
return 80;
}
and it’ll start to draw the “food” row at 80px. Because headers are on top, and because most of header bottom is transparent except for arrow, you should get this effect.
I achieved the desired result in a different way. Instead of using tableView:viewForheaderInSection: (which doesn't work for me), I added an image view that holds the arrow image as a subview of the header view, and set the frame to be just below the header:
// Inside HeaderView.m
UIImageView *arrowImageView = [[UIImageView alloc] initWithImage:self.arrowImage];
arrowImageView.frame = CGRectMake(arrowX, frame.size.height, self.arrowImage.size.width, self.arrowImage.size.height);
[self addSubview:arrowImageView];
[arrowImageView release];
If you watch closely, there are two files (following-captionbubble-dark.png and following-captionbubble-dark#2x.png) in Foodspotting.app which look exactly like the arrow shown above in the question. So I guess they might have used a similar technique. Kudos to the Foodspotting team.
I have a UITableView that I have scroll to the bottom as soon as the user adds another element/table cell to it. For the screen this works fine, because the user can see the cell they just added at the bottom of the table. But when running my app using VoiceOver, the first UITableCell to get focused and read is the top cell that's visible on the screen.
I want to set it so that the cell that gets focused and then read as soon as this UITableView appears is the very last cell in the table. How do I do this? It seems like it would be very simple but I can't figure it out.
Here's what I tried so far (in cellForRowAtIndexPath):
if (cellJustAdded && indexPath.row == [array count]-1) {
cell.accessibilityElementIsFocused = YES; //obviously this does not work
}
but I don't think you can use accessibilityElementIsFocused like that.
When you want VoiceOver to select a certain element you can post an accessibility notification using UIAccessibilityPostNotification( ... );.
Depending on if it's a major (complete screen) change or a minor (layout only) change you should post either
UIAccessibilityScreenChangedNotification (complete change)
UIAccessibilityLayoutChangedNotification (small change)
In both cases the optional argument is the element that VoiceOver should move to.
So after having added the new cell to your table view you would call
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification,
yourNewCellThatShouldHaveFocus);
If I create a UITableViewController - drilling down works as expected. If a user selects a cell and I implement 'didSelectRowAtIndexPath', the cell flashes blue and the next view shows up.
But, if I include an 'edit' button (self.navigationItem.rightBarButtonItem = self.editButtonItem), when the user clicks 'Edit' - the mode correctly changes (all the cells indent and paint an appropriate editingAccessory), ... BUT, the cells are no long 'selectable'.
IE: while in edit mode, when a user selects a cell, nothing is happening. No blue flash. No invocation of 'didSelectRowAtIndexPath', nothing.
When I open the iPhone example 'iPhoneCoreDataRecipes' (as provided in the SDK docs), sure enough, they have a RecipeDetailViewController - that, when put into edit mode, still allows you to drill down. I've downloaded and built their example and it works just fine. I can't seem to find any trickery in their code to enable this 'selectable cell when in edit mode behavior' but I'm just not getting it when I do it.
Thoughts?
Thanks for any time,
-Luther
UITableView has a property allowsSelectionDuringEditing for this.
IMHO it should have been YES by default.
You have to set the allowsSelectionDuringEditing property of UITableView to YES.
The default value is NO.
It can be changed in Storyboard: