Popup displaying image on iPhone app? - ios

I want to show an image in popup view which also contains the close button.
I have searched for that but I did not found any thing about that.
Please help me??

Just try out following simple way -
You can create one UIView that contains UIImageView and UIButton.
Whenever you want to show the the image just assign image to the UIImageView and and show the UIView.
And when you want to hide the the image just hide the UIView on pressing UIButton (i.e close button).
Hope this will help you.

try this for popup
1) ALPopup
2) BlureModelView
3) Ogactionchooser
4) Other and This

- (IBAction)btn:(id)sender {
UIView *contentView;
UIImageView *dot;
contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,300,350)];
contentView.backgroundColor = [UIColor whiteColor];
contentView.layer.cornerRadius = 5.0;
dot =[[UIImageView alloc] initWithFrame:CGRectMake(50,40,200,200)];
dot.image = [UIImage imageNamed:"DSC_0055.JPG.jpg"];
dot.contentMode = UIViewContentModeScaleAspectFit;
[contentView addSubview: dot];
[[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];
}
}
https://github.com/kgn/KGModal

Related

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.

Custom UINavigationBar with custom height in center

I have reviewed almost all questions on OS related to custom NavigationBar but unable to find those solutions helpful. Please have a look on following screenshot,
Red portion represents an icon (small image) in the center of navigationBar.
Please suggest some solution. Thanks in advance.
EDIT: I want to implement that for all UINavigationBar in app. I mean on each view
NOTE: I do not know who is down voting my question but i want to ask a question from those persons. Do you have any solution for my problem? If not, then why you are down voting my question? I will not be able to get help in this way. It's totally wrong.
You can subclass UINavigationBar.
#import "VSNavigationBar.h"
#interface VSNavigationBar ()
#property (nonatomic, weak) UIView *noseView;
#end
#implementation VSNavigationBar
-(void)layoutSubviews
{
[super layoutSubviews];
static CGFloat width = 80;
if (!_noseView) {
UIView *noseView = [[UIView alloc] initWithFrame:CGRectMake(self.bounds.size.width / 2 - width / 2, 0, width, width)];
self.noseView = noseView;
self.noseView.backgroundColor = self.barTintColor;
self.noseView.layer.cornerRadius = self.noseView.frame.size.width / 2;
[self addSubview:_noseView];
}
_noseView.frame = CGRectMake(self.bounds.size.width / 2 - width / 2, 0, width, width);
}
#end
And in your Storyboard you would select the NavigationController scene, in the tree view on the left select Navigation Bar and on the right side select the identity inspector and change the class to the subclass.
you need to create an image that looks like central part of the image you have provided and say -
UIImage *image = [UIImage imageNamed: #"logo.png"];
UIImageView *imageview = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = image view;
If you are trying to get circular effect like the bottom of the image you provided, in that case you need to have same image as above and set it as background image of navbar -
[navigationBar setBackgroundImage:[UIImage imageNamed: #"yourImage"] forBarMetrics:UIBarMetricsDefault];

Cannot make programmatically created UITextField editable (iOS)

I created a UITextField programatically, (I do not use storyboard) and added it as a subview to ViewController with this code:
#interface ViewController ()
#property (nonatomic, strong) UITextField *searchLocationBar;
#end
...
#synthesize searchLocationBar;
...
self.searchLocationBar = [[UITextField alloc] init];
self.searchLocationBar.frame = CGRectMake(0.0f, 0.0f, 320.0f, 40.0f);
self.searchLocationBar.delegate = self;
self.searchLocationBar.borderStyle = UITextBorderStyleRoundedRect;
self.searchLocationBar.placeholder = #"a temporary placeholder";
self.searchLocationBar.userInteractionEnabled = YES;
self.searchLocationBar.clearButtonMode = UITextFieldViewModeAlways;
[self.view addSubview:self.searchLocationBar];
However, I cannot enter any text - nothing happens, when I tap on a textfield. It's not overlapped by any other view.
I've checked UITextfield not editable-iphone but no effect
I'm newbie and totally sure I simply miss something - please advice.
Thanks!
EDIT:
One more thing: I have a Google Maps GMSMapView assigned to self.view as
self.view = mapView_; as written in Google API documentation.
After some tests I found that with this declaration all controls work perfectly, but not textfields. I would prefer not to move a map view to any subview as I will need to rewrite lots of things.
Can someone please add any suggestions?
you forget add:
[self.view bringSubviewToFront:self.searchLocationBar];
In Xcode 5 your code should work.Better you check your Xcode version.May be the problem with your code with Xcode versions.You can try by following way.
UITextField *lastName = [[[UITextField alloc] initWithFrame:CGRectMake(10, 100, 300, 30)];
[self.view addSubview:lastName];
lastName.placeholder = #"Enter your last name here"; //for place holder
lastName.textAlignment = UITextAlignmentLeft; //for text Alignment
lastName.font = [UIFont fontWithName:#"MarkerFelt-Thin" size:14.0]; // text font
lastName.adjustsFontSizeToFitWidth = YES; //adjust the font size to fit width.
lastName.textColor = [UIColor greenColor]; //text color
lastName.keyboardType = UIKeyboardTypeAlphabet; //keyboard type of ur choice
lastName.returnKeyType = UIReturnKeyDone; //returnKey type for keyboard
lastName.clearButtonMode = UITextFieldViewModeWhileEditing;//for clear button on right side
lastName.delegate = self; //use this when ur using Delegate methods of UITextField
There are lot other attributes available but these are few which we use it frequently.if u wanna know about more attributes and how to use them refer to the following link.
You can also make property for UITextField.Either way should work fine in Xcode.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextField_Class/Reference/UITextField.html

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;
}

viewWithTag can Use limited Time

I have 3 UIImageView as Thumbnails with tags: 1, 2, 3.
The following method:
- (IBAction)showImage:(UIGestureRecognizer *)sender
{
if (sender.view.layer.borderColor != [UIColor redColor].CGColor)
{
sender.view.layer.borderColor = [UIColor redColor].CGColor;
UIImageView *showFullImage = (UIImageView *)[self.view viewWithTag:sender+10];
[self.view addSubview:showFullImage];
showFullImage setTag:sender+20;
showFullImage.hidden = NO;
}
else
{
sender.view.layer.borderColor = [UIColor whiteColor].CGColor;
UIImageView *hideFullImage = (UIImageView *)[self.view viewWithTag:sender+20];
[hideFullImage removeFromSuperView];
hideFullImage.hidden = YES;
}
So, as you can see, I have 3 UIImageView small, thumbnails, with whiteBorderColor.
Also I have created and added to superView another 3 Images Full Size, same frame, and following tags: 11, 12, 13 also those images are hidden.
Now, I use the above code for this idea:
When I touch one of those 3 thumbnails, the borderColor will be red, and the hidden Full Size image which has tag = thumbnail.tag + 10, will be Visible. If I press again the same thumbnail image, what now has red borderColor, the Full Size image will be hidden, and the border will be white.
The code works, but my problem is: I can show and hide each Full Size image ONLY Twice.
THE IDEA IS THAT THUMBNAILS SHOULD WORK LIKE UIButton with pressed and normal states.
I don't want to use UIButtons.
Thanks
If i understood truely, you must not write below lines.
[self.view addSubview:showFullImage];
and
[hideFullImage removeFromSuperView];
Also you reset tag after hide.
[hideFullImage setTag:sender+10];
You add view and hide before you call showImage.
Sound like you forgot to reset your image try this:
UIImageView *hideFullImage = (UIImageView *)[self.view viewWithTag:sender+20];
[hideFullImage removeFromSuperView];
[hideFullImage setTag:sender+10];
hideFullImage.hidden = YES;

Resources