I have grouped table view. I want to add UISegmentedControl in table cell with clear background so that it will be displayed as FOOTER . How can I do this? I tried using clearColor. But it's not working.
Set the background view with a clear UIView object like so:
UIView *clearView = [[UIView alloc] initWithFrame:CGRectZero];
[clearView setBackgroundColor:[UIColor clearColor]];
[self setBackgroundView:clearView];
[clearView release];
And make sure you set cell selection style to none.
Edit: added some square brackets
Related
I've requirement to create dynamically some controllers. In the image provided here I've programmatically added an UITextField (name), which hides UITableView.
UITableView is hidden by default. When user touches the UIButton above it, UITableVIew gets appear.
My question when UITableView gets appear, how can I make UITableView top of all other controls?
you will have to change the sequence.
Add UItextfield first
[self.view addSubview:yourTextField];
and add tableview and other views after that line of code so that they appear above it.
[self.view addSubview:yourTableView];
Try
[self.view bringSubviewToFront: yourTableView];
I think this will work fine so please implement this one.
UITextField *txtFld = [[UITextField alloc] initWithFrame:CGRectMake(65, 300, 200, 30)];
txtFld.backgroundColor = [UIColor clearColor];
// Border Style None
[txtFld setBorderStyle:UITextBorderStyleNone];
[txtFld setPlaceholder:#"Name"];
[self.view addSubview:txtFld];
I made a popover containing sectioned tableView with some background. I want to remove that thin vertical border line, which is present on sides between two sections.
set view's background color or image to your custom color/image then and set tableview's background to nil. It should work.
- (void)viewDidLoad
{
[super viewDidLoad];
//background image
self.view.backgroundColor= [UIColor clearColor];
self.view.backgroundColor=[[UIColor alloc] initWithPatternImage:[UIImage imageNamed:#"yourimage.png"]];
//table background image, mytableview should be your tableView's name you can try self.tableView if you have not set/delegate anything to it.
self.mytableView.backgroundView = nil;
}
I've got an app with several UITableViews in it, and if one of them is empty, I'd like to display a bit of help text, floating in front of the UITableView:
"Looks like you haven't created anything for this list yet. Make your first entry by tapping the button above."
How do I present this view, floating in front of the UITableView?
What method of the UITableViewDelegate would be used to present this view?
What would the code look like to present the view?
What method of the UITableViewDelegate would be used to hide this view once the user adds content?
Here's a quick mockup:
declare in .h file
UIView *root;
in .m file
import QuartzCore/QuartzCore.h
- (void)viewDidLoad
{
[super viewDidLoad];
root = [[UIView alloc] initWithFrame:CGRectMake(60, 50, 220, 250)];
root.backgroundColor=[UIColor grayColor];
root.layer.cornerRadius=10;
UILabel *label=[[UILabel alloc] initWithFrame:CGRectMake(10, 100, 200, 50)];
label.backgroundColor=[UIColor clearColor];
label.numberOfLines=3;
label.font=[UIFont fontWithName:#"Arial" size:14];
label.lineBreakMode=UILineBreakModeTailTruncation;
label.textColor=[UIColor whiteColor];
label.text=#"Make your first entry by tapping the button at the top of the screen";
[root addSubview:label];
[self.view addSubview:root];
}
inside your button Event method
[root removeFromSuperview];
in viewDidLoad/Appear,
create a view and add it as subview [self.view addSubview:infoView] . on click event of + button remove it from superview [infoView removeFromSuperView]
I would create/remove the view in numberOfRowsInSection (if it is 0 then show the view) or whatever it is called. As for the view itself, have a UILabel in a custom view. To add the rounded corners etc you can access the view's layer, which is a CALayer. Oh and make sure that you have an ivar for the view so you can remove it easily and check if it is visible. And make sure you always reload the table view when you show your view, as otherwise numberOfRowsInSection will not be called.
Im trying to add views inside custom UITableViewCells. I tried using the [cell.contentView addSubview] method but the views dont appear. What is it I have to do. Thanks
if you are using custom cell then go to your custom cell class and ...
UIView *contentView;
contentView =[[UIView alloc]init];
then set frames of your view...
finally
[self.contentView addSubview:contentView];
So I'm creating a settings page in my app and up to now I've set it up with a grouped table view with both group titles and settings/cell tiles.
At this point I'd like to add UISwitches (Already have their properties set up) to each cell. How can I do that?
The easiest way is to add a UISwitch as the accessory view for the UITableViewCell.
UISwitch* aswitch = [[UISwitch alloc] initWithFrame:CGRectZero];
aswitch.on = YES; // or NO
cell.accessoryView = aswitch;
[aswitch release];