Custom UITable in FBFriendPickerViewController - ios

I would like to know if there is any way to completely replace FBFriendPickerViewController's UITableView or modify the current one.
I need to reverse colors on the table ( white labels, black background) and I wasn't able to do that. So far, I was able to replace table's background but nothing else worked.
I tried something like:
self.myFriendPicker = [[FBFriendPickerViewController alloc] init];
self.myFriendPicker.delegate = self;
[self.myFriendPicker loadData];
[self.myFriendPicker clearSelection];
self.myFriendPicker.allowsMultipleSelection = NO;
self.myFriendPicker.view.frame = CGRectMake(30, 50, 250, 340);
And then I tried to create a new UITableView with red background to try it out and see if it works.
UITableView *tbView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 100, 100) style:UITableViewStylePlain];
tbView.backgroundColor = [UIColor redColor];
self.myFriendPicker.tableView = tbView;
It didn't work and I would appreciate some suggestions.
Thanks for help.

I ended up implementing my own fabecookfriendpicker as a subview of uitableview.Displayinging the list of your friends is not a big issue but even though It is not a straightforward task since you need to lazy load the images and so on.
You have more opportunities to custumize the view with approach.But you can also try subclassing the FBFriendPickerViewController itself

Related

UITextField RightView crash app when using 2 or more

I don't know if this is a bug or what but I can't understand why it happens.
I have 2 UITextField that once clicked show the users an UIPickerView, everything was working fine until I tried to add a custom arrow image in order to let the user know about the dropdown. this is the code I've used in order to create the rightView:
UIImageView *arrowDown = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"p-dropdown"]];
arrowDown.frame = CGRectMake(0, 0, 26, 22);
_province.rightViewMode = UITextFieldViewModeAlways;
_province.rightView = arrowDown;
_address.rightViewMode = UITextFieldViewModeAlways;
_address.rightView = arrowDown;
As soon as the last line ends the app freezes and it starts using like 20MB/s of RAM without stopping, I tried to comment all the code above and the problem doesn't occur, the funny thing is that if I comment just one of the two rightView ,so something like this:
UIImageView *arrowDown = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"p-dropdown"]];
arrowDown.frame = CGRectMake(0, 0, 26, 22);
_province.rightViewMode = UITextFieldViewModeAlways;
_province.rightView = arrowDown;
I can correctly see the rightView and the app doesn't freeze. Can someone help me to understand what is causing this weird issue?
One instance of UIView can't be utilized as right view of multiple UITextFields. You have to make two instances of your UIImageView to make your app work as expected. As you yourself found out, that one view cant be displayed on a screen multiple times simultaneously.

Set Tableview background with Image and Label

I have searched all over but haven't found the answer that works for me.
I just want a tableview background to be set with an Image and a Text below the image when there are no items in the tableview. Like this:
http://i.stack.imgur.com/7DZa5.png
It also has to be in the center and has to work in both iPhone and IPad.
I have tried setting the tableview background to an ImageView but I can't get the label to be positioned below the image. I have also tried creating a separate .xib file for this but I can't get it to work. Please help!
Do you believe in magic ? Kidding...
I believe its not the background of table view. Whenever the array populating your table view contains no data, you need to remove the table view (_tableView.hidden = YES; WILL WORK) and add this custom view with your image and label.
Why don't you set the UITableView's background property to clear. Then just set the image as the background of the view it self? Using AutoLayout will help you keep it centre at all times.
Hi i have done it using ImageView and setting a label inside the imageview.. then adding the imageview as the background for the tableview. It works on iphone and ipad. here is the code:
UIImage *image = [UIImage imageNamed:#"ico_file_list_not_found.png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
imageView.image = image;
[imageView setContentMode:UIViewContentModeCenter];
UILabel *messageLbl = [[UILabel alloc] initWithFrame:CGRectMake(self.tableView.bounds.size.width/2 - image.size.width / 2 + (image.size.width/7),
self.tableView.bounds.size.height/2 + image.size.height / 2
, 120, 21)];
messageLbl.text = #"No files found.";
[imageView addSubview:messageLbl];
self.tableView.backgroundView = imageView;
thank you
It work for you
1> IBOutlet lblTextlable and imgNoItem
2> you set the UITableView's background property to clear.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
if (arrTableListItem.count==0) {
lblTextlable.hidden = false;
imgNoItem.hidden = false;
}
else {
lblTextlable.hidden = true;
imgNoItem.hidden = true;
}
return arrTableListItem.count;
}
As I see in that image, it's the label and image. So the code logic maybe as follow:
If there is no item in list view, hide it and "show" the image / label.
If there are at least one item in the list view, show the list view and hide the Image / Label.

Is UICollectionView.backgroundView broken

I'm writing something relatively simple, or so I thought.
Firstly, the code, for which I'm trying to place an image on the background of the UICollectionView if there are no results returned from my server. The image is 200 by 200:
UIView *myView = [[UIView alloc] initWithFrame:self.view.bounds];
CGRect myViewSpace = self.view.bounds;
CGFloat myX = (myViewSpace.size.width /2.0) - 100;
CGFloat myY = (myViewSpace.size.height /2.0) - 100;
UIImageView *imView = [[UIImageView alloc] initWithFrame:CGRectMake(myX, myY, 200, 200)];
imView.image = [UIImage imageNamed:#"imNotHome"];
[myView addSubview:imView];
myCollectionView.backgroundView = myView;
Once there are results, I want to be able to remove it.
I thought it'd be as simple as placing the following, before I reloaded the UICollectionView:
[myCollectionView.backgroundView removeFromSuperview];
However, it appears to be doing nothing.
Am I missing something?
Thanks in advance!
It should be done this way instead:
myCollectionView.backgroundView = nil;
Explanation: You should unset the UICollectionView's background in the same way as you set it. You didn't set it by manipulating the view hierarchy, but by setting the background property. You did call addSubview in the previous line, but that was to add a subview to your background view, not to add the background view itself.
Edit:
There is a very good article about this UICollectionView bug here:
http://blog.spacemanlabs.com/2013/11/uicollectionviews-backgroundview-property-is-horribly-broken/
The solution the author gives is to reset the background to an empty opaque view:
UIView *blankView = [UIView new];
blankView.backgroundColor = [UIColor whiteColor];
[myCollectionView.backgroundView removeFromSuperview];
myCollectionView.backgroundView = blankView;
Also, the author recommends not using the backgroundView property at all but doing it yourself:
Frankly, I think the best solution is to just ignore the backgroundView property all together. Instead, make the collection view’s background clear, and implement your own backgroundView; just throw a view behind the collection view.

How do I make the area on the top of a UISearchBar (when on a UITableView) in iOS 7 transparent?

Here is a picture describing the problem. Notice that the area above the UISearchBar does not have the background as below it. I don't want the gray color, I want the dark maroon background when pulling down on the UITableView.
Everything I know of is set to [UIColor clearColor], including backgrounds of views, etc. It works fine in iOS 6 but not iOS 7!
I've also attached a sample project so someone can take a look and see what I am doing wrong here?
Click here to download my sample project
Maybe I am just missing something stupid?
Thanks!
Two things you could do: 1) add an explicit clear background view to the UITableView. Or, 2) set your UIImageView to be the background view of the UITableView.
Either of these work. Here's the code that makes your sample work:
- (void)viewDidLoad
{
[super viewDidLoad];
UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
backgroundImageView.image = [UIImage imageNamed:#"Film_bg.png"];
[self.view addSubview:backgroundImageView];
[self.view sendSubviewToBack:backgroundImageView];
// solution 1
// self.tableView.backgroundView = [UIView new];
// self.tableView.backgroundView.backgroundColor = [UIColor clearColor];
// solution 2
self.tableView.backgroundView = backgroundImageView;
}

How to place UIStepper vertically?

I am developing a products storage app and need to implement a UIStepper in it. The problem is that I just can't place it vertically as I would like to have it.
So does anyone know a way I can do this??
You should be able to modify the transform:
stepper.transform = CGAffineTransformMakeRotation(M_PI / 2.0);
Edit:
I now see that this is problematic for IB. I often create my views programmatically and this does not seem to be an issue:
UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(150, 150, 27, 94)];
// this doesn't even have a problem:
UIStepper *stepper = [[UIStepper alloc] init];
It only seems to be an issue with IB. Setting the frame after the fact also does not seem to help.

Resources