HTML marquee not working in iOS 5.1 - iphone

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

Related

UISegmentedControl Color Issue - Color Shows Fine on Simulator, Not on Device

FIXED!
You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool! Hope this helps anyone else who encounters the same issue.
Sorry folks, and thanks for all the input! Great community here.
Original Question:
So a simple test iPhone app in Xcode 4.5:
Create a view with a UISegmentedControl via Storyboard, and set the color via attributes inspector.
Run it on simulator, color shows fine:
Run it on device, color is see-thru/clear.
(Yes in this example above I have colored individual segments, but I even created a new project, added segment control to the view (Bar Type) and it came out see thru!? What gives?
Anyone experienced this before and have and advice on how to correct this?
Thanks
Your simulator might have cached the older images you used before. Clean your simulator and entire project to make sure the images are properly loaded on your simulator.
Try pasting below code
- (void)viewDidLoad
{
UISegmentedControl *segmentControl=[[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:#"1",#"2",nil] ];
[segmentControl setSegmentedControlStyle:UISegmentedControlStyleBar];
[segmentControl setFrame:CGRectMake(20, 20, 200, 30)];
[self.view addSubview:segmentControl];
[segmentControl addTarget:self action:#selector(changeSegment:) forControlEvents:UIControlEventValueChanged];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)changeSegment:(UISegmentedControl*)sender
{
for (int i=0; i<[sender.subviews count]; i++)
{
UIColor *tintcolor;
if ([[sender.subviews objectAtIndex:i]isSelected] )
{
tintcolor=[UIColor redColor];
[[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
}
if (![[sender.subviews objectAtIndex:i]isSelected]){
tintcolor=[UIColor grayColor];
[[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
}
}
}
It's possible you have the Opaque option unchecked in the Drawing section of the View Attributes.
I vaguely recall having an issue similar to this where the behaviour on the emulator was different from that of the device and it was related to the Opaque setting.
You won't believe it... It was a Winterboard theme messing with it! The bugger! Disabled theme and voila, works perfectly. The theme in question was "Ayecorn" for anyone interested. Not cool!
Thanks for all the input guys! Great community here!

GIF Support for Iphone

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.

TTPhotoViewController: deactivate gallery auto zoom

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.

Why can't I capture a screenshot of MPMoviePlayerController?

I need to capture a screen shot of a video playing in mpmovieplayer controller, but all I get is a red screen (I made the coverView with red background and 0.5 alpha).
Here is the code:
NSArray *windows = [[UIApplication sharedApplication] windows];
if ([windows count] > 1)
{
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
UIView *coverView = [[UIView alloc] initWithFrame:moviePlayerWindow.bounds];
[mainController.moviePlayer pause]; //Without that it won't work either!
coverView.backgroundColor = [UIColor redColor];
coverView.alpha = 0.5;
[moviePlayerWindow addSubview:coverView];
UIGraphicsBeginImageContext(coverView.bounds.size);
[coverView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *screenShot;
screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(screenShot, self, nil, nil);
}
Any ideas???
Thanks
I was curious about his myself. I believe there are similar issues with taking screenshots of OpenGL stuff too.
If you look at this blog post http://getsetgames.com/2009/07/30/5-ways-to-take-screenshots-of-your-iphone-app/, they have a method that works for an EAGLView, it might be worth giving it a go for your issue.
Follow up to the question:
Recently I have a project that requires the functionality that was asked in this thread again, and I am glad to say there is already an apple provided solution to this. I am posting this so that people that visit this thread can get an answer.
MPMoviePlayerController now has a method that return a UIImage of the moment you want to capture.
- (UIImage *)thumbnailImageAtTime:(NSTimeInterval)playbackTime timeOption:(MPMovieTimeOption)option
Just put in the playbackTime you want to capture, and bingo, UIImage.
Looking at your codes, I would like to advise that you should look for an alternative method of getting the image rather than from the mpmovieplayer itself. The reason being that the method you are using is a private framework code, and second, getting screenshots off a video is highly prone to crashes.
Instead of getting a screenshot from the video, how about tagging the video beforehand? The codes looks highly vulnerable to an app rejection by apple.
Sounds like you're taking a shot of the video overlay mask
http://en.wikipedia.org/wiki/Hardware_overlay

iPhone - Is it possible to hide native scrollbar in UIWebView?

I would like to hide the native scrollbar / scroller that appears when you are scrolling a UIWebView, but still keep the scrolling functionality intact. Is this possible?
Thanks in advance,
William
It seems this question needs an updated answer:
You can directly access the scroll view associated with the web view. (read-only)
in iOS 5.0 an above.
I don't think developers should be supporting anything prior to iOS 5.0 unless in exceptional circumstances.
From the Apple developer docs.
#property(nonatomic, readonly, retain) UIScrollView *scrollView
Discussion
Your application can access the scroll view if it wants to customize the scrolling behavior of the web view.
Availability
Available in iOS 5.0 and later.
Declared In
UIWebView.h
Now you can directly write something like this:
webView.scrollView.showsHorizontalScrollIndicator = NO;
webView.scrollView.showsVerticalScrollIndicator = NO;
No need to go to the subviews of the webView.
UIWebView doesn't inherit directly from UIScrollView, but you may be able to use UIScrollView properties on the UIWebView subview:
[(UIScrollView*)[webview.subviews objectAtIndex:0] setShowsHorizontalScrollIndicator:NO];
[(UIScrollView*)[webview.subviews objectAtIndex:0] setShowsVerticalScrollIndicator:NO];
No idea if this is acceptable, but it builds okay and I think it should work. Please report back if this works for you.
Also consider filing a feature request to Apple at bugreport.apple.com to add this property to a future UIWebView implementation.
Do it in that way:
for (id subview in self.myWebView.subviews) {
if ([[subview class] isSubclassOfClass: [UIScrollView class]]) {
((UIScrollView *)subview).bounces = NO;
((UIScrollView *)subview).showsVerticalScrollIndicator = NO;
((UIScrollView *)subview).showsHorizontalScrollIndicator = NO;
}
}
In Swift :
webView.scrollView.showsHorizontalScrollIndicator = false
webView.scrollView.showsVerticalScrollIndicator = false
If someone is looking for swift solution then below is the code for swift 3.0
yourWebView.scrollView.showsHorizontalScrollIndicator = false
yourWebView.scrollView.showsVerticalScrollIndicator = false
There's seems to be the beginning of an answer here :
http://discussions.apple.com/thread.jspa?threadID=1781730
If you disable user interaction, this seems to remove the scrollbar (this may be ok if the web page you display does not exceed the screen height).
A kind of javascript hack seems to be described also but I'm not mastering it :/ (you need to have access to the web page you try to display however, and this may not be your case....)