In my project, I use the Facebook API "three20": https://github.com/facebook/three20/
Now, I need to customize the TTPhotoViewController.
In the gallery, there's an "auto zoom". The complete width and height are always used:
The disadvantage is that you can not see the complete photo and important information could be cut off / cropped.
How can I deactivate the automatic zoom?
Thanks!
EDIT 03-Mar-2011:
Roman's answer seems to be good, but unfortunately it doesn't helps me. Yes, the content mode UIViewContentModeScaleAspectFill is the problem:
Scales the content to fill the size of
the view. Some portion of the content
may be clipped to fill the view’s
bounds.
But there's no other content mode that solves my problem. I think, I have to look deep inside three20 and scale the images by myself. But I need your help to do this! So, I'll start a new "bounty" today (03/03/2011)...
Thank you very much!!
EDIT 07-Mar-2011:
Finally I got it!! roman's answer is right, I have to use UIViewContentModeScaleAspectFit.
The problem was: I use a wrong size in my Photo-Object! 320x480 worked for me:
NSMutableArray *photos = [NSMutableArray new];
for (Information *info in allImages) {
NSString *binaryId = info.binary;
NSString *fileName = [NSString stringWithFormat:#"documents://img/%#.jpg", binaryId];
Photo *photo = [[[Photo alloc] initWithCaption:info.name
urlLarge:fileName
urlSmall:fileName
urlThumb:fileName
size:CGSizeMake(320, 480)] autorelease];
[photos addObject:photo];
}
self.photoSource = [[PhotoSet alloc] initWithTitle:#"Photos" photos:photos];
easiest way is to hack TTPhotoView - around line 135 (function setImage) change
self.contentMode = UIViewContentModeScaleAspectFill;
to
self.contentMode = UIViewContentModeScaleAspectFit;
sadly there does not seem to be another way currently.
You should award your question to roman because he answers your specific question, but I want to suggest that you should consider not using three20 and implement your image scroller yourself. Take a look at Session 104, Designing Apps with Scroll Views (requires ADC login) from the WWDC 2010 session videos on iTunes. It walks you through exactly how to implement this type of interface and allows you to keep your app lean without having to add the entire three20 library to your code.
Make this change in TTScrollView class
In the method
- (CGRect)frameOfPageAtIndex:(NSInteger)pageIndex
In this method, change the following line
if (size.width > size.height) {
to
if (size.width / size.height > self.width / self.height) {
This worked for me.
Related
My Sires, My Dames (ah.. just another knightly thing,...)
I have a question, I have been battling with this for days, here's my scenario:
I have an HTTP response which contains a link to a GIF Image, the GIF image then is converted into an NSData, and later on used to populate an ImageView. Expectedly or Unexpectedly, only the first frame/transition of the GIF is shown. Simply said, the image loads but doesn't animate.
What I want to know if there is native support for GIF in iPhone, likewise I found an extended class here SCGifExample
which seems to appear to work only when I import the GIF image within the app, but not when the image is coming from a URI->NSData.
I don't want to create multiple images then create an array of images because that is not gonna work my setup as it will give a lot of load to the server and the client.
I've made my search here at SO, but I didn't found any substantial result to stop me from posting my own question as a matter of fact I found many questions here related to iphone+gif are left unanswered.
I do have a suspicion, and I was hoping somebody could help me figure out and understand it. I suspect that the GIF Animation/Transition is "LOST" during the conversion from Image to NSDATA format. But I don't have any concrete evidence to back this up tho.
Here's how I convert the image into NSData;
contentURI = http://gta.champion.com/content?cmsFileId=513af9e9-a96d-4a56-8239-92be273393e0&mt=image/gif //lets just assume that when view using the browser, this would display the image.
NSData * imageData = [[NSData alloc] initWithContentsOfURL: [NSURL URLWithString: contentURI]];
If there was somebody else who came victor of this plight, please help me to conquer such feat also.
Yes there is an alternate , but it depends on the case you have.But let me share the idea with you because using the UIWebView solved my problem since I just need to Animate a single image i.e Advertisement.
Here is the code Snippet :
UIWebView *webV = [[[UIWebView alloc]initWithFrame:appDel.isiPad==TRUE?CGRectMake(260, 35, 500, 100):CGRectMake(40, 18, 250, 60)] autorelease] ;
webV.delegate =self;
webV.multipleTouchEnabled=NO;
[webV setBackgroundColor:[UIColor whiteColor]];
webV.userInteractionEnabled=NO;
[webV loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:#"YourImageUrl"]]];
And implement their delegate methods :
- (void)webViewDidStartLoad:(UIWebView *)webView;
- (void)webViewDidFinishLoad:(UIWebView *)webView;
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error;
While Apple's APIs do not support animated GIFs out-of-the-box, there is a user-created solution that is just as effective:
LBGIFImage:
https://github.com/larcus94/LBGIFImage
Unfortunately iOS does not support GIF images, also you cannot use them for animations. If you use GIF images, the imageview will show the first frame of that image, nothing more.
Please refer UIImage for the supported formats.
See what I found out about showing animated gif in iOS. http://iosnotestoremember.blogspot.com/2013/01/showing-animated-gif-in-ios.html
I hope this helps.
Please see below function.
-(void)loadHTMLinWebView
{
objWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
objWebView.opaque = NO;
objWebView.userInteractionEnabled = NO;
objWebView.backgroundColor = [UIColor clearColor];
NSString *strTemp = #"<html><body style="margin-top:0px; margin-left:0px; text-align:center"><marquee behavior="alternate" style="font-family:Marker Felt;font-size:20px; color:#A52A2A;">Test</marquee></font></body></html>";
[objWebView loadHTMLString:strTemp baseURL:nil];
[self addSubview:objWebView];
}
Above is the code that I had written for loading HTML in UIWebView.
But when I am running this code in iOS 4.0 device, It is working well and I saw marquee effect in Webview but running this code in iOS 5.1 device, It is not showing the marquee effect, It is just showing the text.
Don't know what is happening there.
Please help me to solve this problem.
Thanks in advance.
Checking your code I found that behavior="alternate" is causing problem to stop scrolling. If you put behavior="scroll" than it will scroll but not as per your requirement.
If you look for alternates than there is other answer which may be helpful to you.
Here are few links to discussion which discuss this problem and recommends not to use marquee.
link1
link2
link3
Update
Wowo ! This is something interesting. I checked again and found that it does work but not for small strings. It works for somewhat large strings. Still no clue about the problem.
AS alternative you can create same thing with UIView and Timer. Please refer below URL
https://github.com/jeffhodnett/JHTickerView
https://github.com/MugunthKumar/MKTickerViewDemo
https://github.com/caydenliew/CLTickerView
Are there any built in, open source, or tutorials for creating a reusable easy to use popup for use with in game-help.
Essentially I would like to, on first run of a game, show popup tips / help that "point to" various on screen objects to help a user orient themselves with the game.
Update: Here is an example of how I ultimately want it to look / behave although I don't need it that generic but as close as possible would be good
I like those: https://github.com/chrismiles/CMPopTipView.
Nice and easy to set up.
Essentially what you need is a custom view.
You cannot use Apple's UIAlertView since its purpose is very different from what you are looking for.
I don't know what are your specific needs, but you may use a simple UILabel:
CGRect ref = objectToAddress.frame;
UILabel *tip = [[UILabel alloc] initWithFrame:CGRectMake(ref.x+ref.width,
ref.y+ref.height,
width,
height)];
[tip setText:messageToShow];
[self.view addSubview:tip];
[tip release];
where width and height are the dimensions of the tip you want to show and messageToShow is the message you want to display.
You can, of course, customize your UILabel as you like, changing font or background color. Check the reference for additional informations.
EDIT:
You may take a look at a possible popover implementation for iPhone: WEPopover. On the iPad you can use directly Apple's UIPopoverController
What I've done is to create two functions
- (void) showOverlay: (BOOL) show withMessage: (NSString*) message
{
if(show)
{
// I create or load a UIView with labels, etc, and with an alpha of 0.6/07
// give it a tag for later dismissal
overlay.tag = tag; // any arbitrary value
// add as subview
[self.view addSubview: overlay];
}
else
{
// hide the view
UIView *overlay = [self.view viewWithTag: tag];
[overlay removeFromSuperview];
}
}
Then I have a hide overlay function
- (void) hideOverlayInSecs: (NSInterval) time
{
[self performSelector: #selector(hideOverlay) withObject: nil afterDelay: time];
}
Then you can write a wrapper function to show / dismiss it for varying durations
[self showOverlay: YES withMessage: #"help tip"];
[self hideOverlayInSecs: 2];
In my App, the tips were fairly static, so I created an tip image using my favorite image editor, and then simply created a UIImageView with the tip image, and then added that as a subview to the current view, making sure to place it on top of other views.
It worked out pretty nicely, but again, my tips are fairly static.
If you want to display them only on the first run through, you'll need to create a BOOL that is saved in NSUserDefaults or something.
How about this?
I wrote this myself. It's pretty simple and probably what you are looking for.
Popup any UIView instance on top or bottom then disappear after a few seconds.
https://github.com/SaKKo/SKTipAlertView
Hope you find it useful. cheers,
I have seen many times waiting panels (panels with a uiactivityindicatorview) black/dark with some transparency and white labels.
Like this one :
I guess it is a standard element.
Where can I find it?
Try This. it's the best solution I came across to show the activity. MBProgressHUD
MBProgressHUD looks nice. You might want to check out http://code.google.com/p/toast-notifications-ios/ too.
There's no iOS component that does this.
If you don't want to include an external library just for this one component then you can do it using UI components.
/* Warning, typed from memory */
// Create the UIView that's the background
UIView *pleaseWaitView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 80)];
[pleaseWaitView setBackgroundColor:[UIColor colorWithWhite:0.5 alpha:0.5]];
[[pleaseWaitView layer] setCornerRadius:5.0f];
// And create an activity indicator
UIActivityIndicator *i = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[i startAnimating];
[pleaseWaitView addSubview:i];
[i release];
// Add it to the main view (in the middle)
[pleaseWaitView setCenter:CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2)];
[self.view addSubview:pleaseWaitView];
You can add a UILabel with whatever text you want (in your case, 'Authenticating') in the same way as you added the activity indicator.
The tricky part is setting the corner radius - you will probably need this at the top of your .m file :
#import <QuartzCore/QuartzCore.h>
NB You can do this in interface builder as well if you want (apart from the corner radius bit!) ;)
I answered a question that included an overlay like this. I included the code and the overlay image you need to do it with. Take a look at this answer and take a look at the screen shot it created. I use this overlay as I send email in the background so you will want to edit the code to do your function but the overlay code is already in place.
Locking the Fields in MFMailComposeViewController
Happy Coding!
Check out DSActivityView. I've successfully used it in a few of my projects.
As by now there is no standard UIElement for that in iOS.
But checkout this library:
As per the question, I'm looking to implement a video selector with different categories. This would be very similar to the BBC app in approach. I don't seem to be able to find anything that fits the bill though, has anyone got any good ideas for how I might be able to do this/an API freely available that does it. See example:
http://www.bbc.co.uk/blogs/bbcinternet/img/BBC_News_app_portrait_BBC_copyright.PNG
You have to use scrollview instead of tableview for this case.
You can make a custom view for each of the news items and can be added to the scrollview.
The easiest way to do this would be to create a simple UITableView and, inside each cell, create a UIScrollView :)
UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,100)];
myScrollView.delegate = self;
myScrollView.contentSize = CGSizeMake(2000,100);
for(int i = 0; i < [myData count]; i++) {
// Add your content here
}
You can start from this pageControl sample code. It has horizontal scrolling with pages.
I suggest to use three20 classes.
There are downloadable from here: https://github.com/facebook/three20
In sample code you can find horizontally table scroll.
Easy and beatiful!
A
Here is a great tutorial, with example project showing an effective way to implement vertical and horizontal scrolling.
http://www.raywenderlich.com/4680/how-to-make-an-interface-with-horizontal-tables-like-the-pulse-news-app-part-1