Search Results

Search found 369 results on 15 pages for 'subview'.

Page 15/15 | < Previous Page | 11 12 13 14 15 

  • iPhone SDK can't get UIScrollView to work with a UIWebView

    - by Maxwell Segal
    I am building an app that in part of it has two views - one portrait and one landscape. And I want to offer scrolling and pinch & zooming on the landscape orientation. I've built the two views and the simple UIImages in the landscape view all work OK but it does not seem to insert my UIWebView into the UIScrollView. I've done this before with UIImage and all was OK but I must be missing something here - can anybody help with some advice. I'm sure it's something very simple - perhaps to do with the adding of the subview??. Thanks in advance of your help. I've shown the relevant parts of my code below: @interface MonthViewController : UIViewController <UIScrollViewDelegate> { MonthViewController *monthController; IBOutlet UIView *portraitView; IBOutlet UIView *landscapeView; IBOutlet UIWebView *monthKWHChartPortrait; UIWebView *monthKWHChartLandscape; IBOutlet UIScrollView *scrollChartLandscape; IBOutlet UIImageView *eLogoPortrait; IBOutlet UIImageView *eLogoLandscape; IBOutlet UIImageView *clientLogoPortrait; IBOutlet UIImageView *clientLogoLandscape; IBOutlet UIActivityIndicatorView *loadIndicatorPortrait; IBOutlet UIActivityIndicatorView *loadIndicatorLandscape; NSTimer *timer; IBOutlet UILabel *test; } -(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollChartLandscape { return monthKWHChartLandscape; } - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); } -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { [super willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:duration]; if (toInterfaceOrientation ==UIInterfaceOrientationLandscapeRight) { NSLog(@"right"); test.text=@"right"; NSString *urlAddressLandscape = @"http://PRIVATEURLHERE.aspx?WIDTH=440"; NSURL *urlLandscape = [NSURL URLWithString:urlAddressLandscape]; NSURLRequest *requestObjLandscape = [NSURLRequest requestWithURL:urlLandscape]; [self.monthKWHChartLandscape loadRequest:requestObjLandscape]; scrollChartLandscape.contentSize = CGSizeMake(monthKWHChartLandscape.frame.size.width, monthKWHChartLandscape.frame.size.height); scrollChartLandscape.maximumZoomScale = 2.5; scrollChartLandscape.minimumZoomScale = 0.6; scrollChartLandscape.showsHorizontalScrollIndicator = YES; scrollChartLandscape.showsVerticalScrollIndicator = YES; scrollChartLandscape.clipsToBounds = YES; scrollChartLandscape.delegate = self; [self.scrollChartLandscape addSubview:monthKWHChartLandscape]; self.view=landscapeView; //self.view.transform=CGAffineTransformMakeRotation(deg2rad*(90)); //self.view.bounds=CGRectMake(0.0, 0.0, 480.0, 320.0); } else

    Read the article

  • Why does my UIActivityIndicatorView only display once?

    - by Schwigg
    I'm developing an iPhone app that features a tab-bar based navigation with five tabs. Each tab contains a UITableView whose data is retrieved remotely. Ideally, I would like to use a single UIActivityIndicatorView (a subview of the window) that is started/stopped during this remote retrieval - once per tab. Here's how I set up the spinner in the AppDelegate: - (void)applicationDidFinishLaunching:(UIApplication *)application { [window addSubview:rootController.view]; activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; [activityIndicator setCenter:CGPointMake(160, 200)]; [window addSubview:activityIndicator]; [window makeKeyAndVisible]; } Since my tabs were all performing a similiar function, I created a base class that all of my tabs' ViewControllers inherit from. Here is the method I'm using to do the remote retrieval: - (void)parseXMLFileAtURL:(NSString *)URL { NSAutoreleasePool *apool = [[NSAutoreleasePool alloc] init]; AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; NSLog(@"parseXMLFileAtURL started."); [appDelegate.activityIndicator startAnimating]; NSLog(@"appDelegate.activityIndicator: %@", appDelegate.activityIndicator); articles = [[NSMutableArray alloc] init]; NSURL *xmlURL = [NSURL URLWithString:URL]; rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL]; [rssParser setDelegate:self]; [rssParser setShouldProcessNamespaces:NO]; [rssParser setShouldReportNamespacePrefixes:NO]; [rssParser setShouldResolveExternalEntities:NO]; [rssParser parse]; NSLog(@"parseXMLFileAtURL finished."); [appDelegate.activityIndicator stopAnimating]; [apool release]; } This method is being called by each view controller as follows: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; if ([articles count] == 0) { NSString *path = @"http://www.myproject.com/rss1.xml"; [self performSelectorInBackground:@selector(parseXMLFileAtURL:) withObject:path]; } } This works great while the application loads the first tab's content. I'm presented with the empty table and the spinner. As soon as the content loads, the spinner goes away. Strangely, when I click the second tab, the NSLog messages from the -parseXMLFileAtURL: method show up in the log, but the screen hangs on the first tab's view and I do not see the spinner. As soon as the content is done downloading, the second tab's view appears. I suspect this has something to do with threading, with which I'm still becoming acquainted. Am I doing something obviously wrong here?

    Read the article

  • UITableView not getting populated

    - by jayshree430
    Hi. I have a peculiar problem. I created a normal Objective c class called SampleTable. I then extended UITableView instead of NSObject. Then in the initWithFrame constructor i initialized the table. I also made a NSMutableArray object for the datasource. I also conformed UITableViewDelegate and UITableViewDatasource. I have overridden the necessary methods also. Now i made an object of this class in another class, and added the object as a subview. The tableView is getting drawn according to the CGRectMake() coordinates i gave to the initWithFrame constructor. But it is not getting populated with the data. I dnt know what the problem is . Can plz someone help me. SampleTable.h #import @interface SampleTable : UITableView { NSMutableArray *ItemArray; } @property (nonatomic,retain) NSMutableArray *ItemArray; -(NSMutableArray *) displayItemArray; @end SampleTable.m #import "SampleTable.h" @implementation SampleTable @synthesize ItemArray; -(id)initWithFrame:(CGRect)frm { [super initWithFrame:frm]; self.delegate=self; self.dataSource=self; [self reloadData]; return self; } -(NSMutableArray *) displayItemArray { if(ItemArray==nil) { ItemArray=[[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",nil]; } return ItemArray; } (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [ItemArray count]; } (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell= [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell==nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; [cell autorelease]; } NSString *temp=[self.ItemArray objectAtIndex:indexPath.row]; cell.textLabel.text = temp; return cell; } (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"didselect"); } -(void) dealloc { [ItemArray release]; [super dealloc]; } @end

    Read the article

  • UIScrollView ImageView with pins on top

    - by Koppo
    To all, I have a UIScrollView which has a UIImageView. I want to show pins on this imageView. When I add pins as subviews of the ImageView everything is great except for when you zoom the scale transform happens on the pins also. I don't want this behavior and want my pins to stay the same. So I choose to add the Pins to another view which sits on top of the ImageView and is also a subview of the UIScrollView. The idea here if you will imagine is to have a layer which hovers over the map and won't scale yet show pins over where I plot them. The pin when added to the layer view don't cale if the ImageView scales. However the issue then bceomes the position of the pins doesn't match the original origin x/y as the ImageView has had a scale transform. Basically this is a custom map of a place with Pins. I am trying to have the Pins float over and not zoom in and out over my ImageView yet remember where I placed them when the zoom happens. Some code scrollView = [[UIScrollView alloc] initWithFrame:viewRect]; scrollView.delegate = self; scrollView.pagingEnabled = NO; scrollView.scrollsToTop = NO; [scrollView setBackgroundColor:[UIColor clearColor]]; scrollView.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview scrollView.bounces = YES; scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight; scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite; imageViewMap = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image.png"]]; imageViewMap.userInteractionEnabled = YES; viewRect = CGRectMake(0,0,imageViewMap.image.size.width,imageViewMap.image.size.height); //viewRect = CGRectMake(0,0,2976,3928); [scrollView addSubview:imageViewMap]; [scrollView setContentSize:CGSizeMake(viewRect.size.width, viewRect.size.height)]; iconsView = [[UIView alloc] initWithFrame:imageViewMap.frame]; [scrollView addSubview:iconsView]; Code to add Pin later on some event. [iconsView addSubview:pinIcon]; I am stuck in trying tp figure out how to to get my pins to hover on the map without moving when the scale happens. Thanks

    Read the article

  • iphone initializing tab bar controller view programatically

    - by unsorted
    I want to initialize my tab bar controller programatically, but I just get a blank screen with the code I have. I tried to imitate TheElements sample app, and stuff seems comparable going line-by-line, but obviously something's wrong. Any suggestions? Thanks... In main.m: #import <UIKit/UIKit.h> int main(int argc, char *argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int retVal = UIApplicationMain(argc, argv, nil, @"DubbleWrapAppDelegate"); [pool release]; return retVal; } In DubbleWrapAppDelegate.h: @interface DubbleWrapAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { UIWindow *window; UITabBarController *tabBarController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; @end In DubbleWrapAppDelegate.m: @implementation DubbleWrapAppDelegate @synthesize window; @synthesize tabBarController; - init { if (self = [super init]){ // initialize to nil window = nil; tabBarController = nil; } return self; } - (void)applicationDidFinishLaunching:(UIApplication *)application { SafeTableViewController *vc1 = [[SafeTableViewController alloc] initWithStyle:UITableViewStylePlain]; [vc1 setSafeItems:[SafeItem knownSafeItems]]; // Set the list of known SafeItems: UINavigationController *nc1; nc1 = [[UINavigationController alloc] initWithRootViewController:vc1]; [vc1 release]; BoxXRayTableViewController *vc2 = [[BoxXRayTableViewController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *nc2; nc2 = [[UINavigationController alloc] initWithRootViewController:vc2]; [vc2 release]; AboutLibertyViewController *vc3 = [[AboutLibertyViewController alloc] init]; UINavigationController *nc3; nc3 = [[UINavigationController alloc] initWithRootViewController:vc3]; [vc3 release]; NSArray* controllers = [NSArray arrayWithObjects:nc1, nc2, nc3, nil]; tabBarController = [[UITabBarController alloc] init]; tabBarController.viewControllers = controllers; [controllers release]; // Add the tab bar controller's current view as a subview of the window window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; [window setBackgroundColor:[UIColor redColor]]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; [nc1 release]; [nc2 release]; [nc3 release]; } The plist is set so that there is no NIB file referenced.

    Read the article

  • UITableViewCell with selectable/copyable text that also detects URLs on the iPhone

    - by Jasarien
    Hi guys, I have a problem. Part of my app requires text to be shown in a table. The text needs to be selectable/copyable (but not editable) and any URLs within the text need to be highlighted and and when tapped allow me to take that URL and open my embedded browser. I have seen a couple of solutions that solve one of either of these problems, but not both. Solution 1: Icon Factory's IFTweetLabel The first solution I tried was to use the IFTweetLabel class made possible by Icon Factory and used in Twitterrific. While this solution allows for links (or anything you can find with a regex) to be detected to be handled on a case by case basis, it doesn't allow for selecting and copying. There is also an issue where if a URL is long enough to be wrapped, the button that the class overlays above the URL to make it interactive cannot wrap and draws off screen, looking very odd. Solution 2: Use IFTweetLabel and handle copy manually The second thing I tried was to keep IFTweetLabel in place to handle the links, but to implement the copying using a long-tap gesture, like how the SMS app handles it. This was just about working, but it doesn't allow for arbitrary selection of text, the whole text is copied, or none is copied at all... Pretty black and white. Solution 3: UITextView My third attempt was to add a UITextView as a subview of the table cell. The only thing that this doesn't solve is the fact that detected URLs cannot be handled by me. The text view uses UIApplication's openURL: method which quits my app and launched Safari. Also, as the table view can get quite large, the number of UITextViews added as subviews cause a noticeable performance drag on scrolling throughout the table, especially on iPhone 3G era devices (because of the creation, layout, compositing whenever a cell is scrolled on screen, etc). So my question to all you knowledgeable folk out there is: What can I do? Would a UIWebView be the best option? Aside from a performance drag, I think a webview would solve all the above issues, and if I remember correctly, back in the 2.0 days, the Apple documentation actually recommended web views where text formatting / hyperlinks were required. Can anyone think of a way to achieve this without a performance drag? Many thanks in advance to everyone who can help.

    Read the article

  • Reason why UIImageView gives me a 'distorted' image sometimes

    - by Cedric Vandendriessche
    I have a custom UIView with a UILabel and a UIImageView subview. (tried using UIImageView subclass aswell). I assign an image to it and add the view to the screen. I wrote a function which adds the amount of LetterBoxes to the screen as there are letters in the word: - (void)drawBoxesForWord:(NSString *)word { if(boxesContainer == nil) { /* Create a container for the LetterBoxes (animation purposes) */ boxesContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 205, 320, 50)]; [self.view addSubview:boxesContainer]; } /* Calculate width of letterboxes */ NSInteger numberOfCharacters = [word length]; CGFloat totalWidth = numberOfCharacters * 28 + (numberOfCharacters - 1) * 3; CGFloat leftCap = (320 - totalWidth) / 2; [letters removeAllObjects]; /* Draw the boxes to the screen */ for (int i = 0; i < numberOfCharacters; i++) { LetterBox *letter = [[LetterBox alloc] initWithFrame:CGRectMake(leftCap + i * 31 , 0, 28, 40)]; [letters addObject:letter]; [boxesContainer addSubview:letter]; [letter release]; }} This gives me the image below: http://www.imgdumper.nl/uploads2/4ba3b2c72bb99/4ba3b2c72abfd-Goed.png But sometimes it gives me this: imgdumper.nl/uploads2/4ba3b2d888226/4ba3b2d88728a-Fout.png I add them to the same boxesContainer but they first remove themselves from the superview, so it's not like you see them double or something. What I find weird is that they are all good or all bad.. This is the init function for my LetterBox: if (self == [super initWithFrame:aRect]) { /* Create the box image with same frame */ boxImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; boxImage.contentMode = UIViewContentModeScaleAspectFit; boxImage.image = [UIImage imageNamed:@"SpaceOpen.png"]; [self addSubview:boxImage]; /* Create the label with same frame */ letterLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; letterLabel.backgroundColor = [UIColor clearColor]; letterLabel.font = [UIFont fontWithName:@"ArialRoundedMTBold" size:26]; letterLabel.textColor = [UIColor blackColor]; letterLabel.textAlignment = UITextAlignmentCenter; [self addSubview:letterLabel]; } return self;} Does anyone have an idea why this could be? I'd rather have them display correctly every time :)

    Read the article

  • Very simple test view in MonoTouch draws a line using Core Graphics but view content is not shown

    - by Krumelur
    Hi, I give up now on this very simple test I've been trying to run. I want to add a subview to my window which does nothing but draw a line from one corner of the iPhone's screen to the other and then, using touchesMoved() it is supposed to draw a line from the last to the current point. The issues: 1. Already the initial line is not visible. 2. When using Interface Builder, the initial line is visible, but drawRect() is never called, even if I call SetNeedsDisplay(). It can't be that hard...can somebody fix the code below to make it work? In main.cs in FinishedLaunching(): oView = new TestView(); oView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; oView.Frame = new System.Drawing.RectangleF(0, 0, 320, 480); window.AddSubview(oView); window.MakeKeyAndVisible (); The TestView.cs: using System; using MonoTouch.UIKit; using MonoTouch.CoreGraphics; using System.Drawing; using MonoTouch.CoreAnimation; using MonoTouch.Foundation; namespace Test { public class TestView : UIView { public TestView () : base() { } public override void DrawRect (RectangleF area, UIViewPrintFormatter formatter) { CGContext oContext = UIGraphics.GetCurrentContext(); oContext.SetStrokeColor(UIColor.Red.CGColor.Components); oContext.SetLineWidth(3.0f); this.oLastPoint.Y = UIScreen.MainScreen.ApplicationFrame.Size.Height - this.oLastPoint.Y; this.oCurrentPoint.Y = UIScreen.MainScreen.ApplicationFrame.Size.Height - this.oCurrentPoint.Y; oContext.StrokeLineSegments(new PointF[] {this.oLastPoint, this.oCurrentPoint }); oContext.Flush(); oContext.RestoreState(); Console.Out.WriteLine("Current X: {0}, Y: {1}", oCurrentPoint.X.ToString(), oCurrentPoint.Y.ToString()); Console.Out.WriteLine("Last X: {0}, Y: {1}", oLastPoint.X.ToString(), oLastPoint.Y.ToString()); } private PointF oCurrentPoint = new PointF(0, 0); private PointF oLastPoint = new PointF(320, 480); public override void TouchesMoved (MonoTouch.Foundation.NSSet touches, UIEvent evt) { base.TouchesMoved (touches, evt); UITouch oTouch = (UITouch)touches.AnyObject; this.oCurrentPoint = oTouch.LocationInView(this); this.oLastPoint = oTouch.PreviousLocationInView(this); this.SetNeedsDisplay(); } } }

    Read the article

  • UIButton does not respond to touch events after changing its position using setFrame

    - by Pranathi
    I have a view controller class (child) which extends from view controller class (parent). In the parent class's loadView() method I create a sub-view (named myButtonView) with two buttons (buttons are horizontally laid out in the subview) and add it to the main view. In the subclass I need to shift these two buttons up by 50pixels. So, I am shifting the buttonView by calling the setFrame method. This makes the buttons shift and render properly but they do not respond to touch events after this. Buttons work properly in the views of Parent class type. In the child class type view also, if I comment out the setFrame() call the buttons work properly. How can I shift the buttons and still make them respond to touch events? Any help is appreciated. Following is snippets of the code. In the parent class: - (void)loadView { // Some code... CGRect buttonFrameRect = CGRectMake(0,yOffset+1,screenRect.size.width,KButtonViewHeight); myButtonView = [[UIView alloc]initWithFrame:buttonFrameRect]; myButtonView.backgroundColor = [UIColor clearColor]; [self.view addSubview:myButtonView]; // some code... CGRect nxtButtonRect = CGRectMake(screenRect.size.width - 110, 5, 100, 40); myNxtButton = [UIButton buttonWithType:UIButtonTypeCustom]; [myNxtButton setTitle:@"Submit" forState:UIControlStateNormal]; myNxtButton.frame = nxtButtonRect; myNxtButton.backgroundColor = [UIColor clearColor]; [myNxtButton addTarget:self action:@selector(nextButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [myButtonView addSubview:myNxtButton]; CGRect backButtonRect = CGRectMake(10, 5, 100, 40); myBackButton = [UIButton buttonWithType:UIButtonTypeCustom]; [myBackButton setTitle:@"Back" forState:UIControlStateNormal]; myBackButton.frame = backButtonRect; myBackButton.backgroundColor = [UIColor clearColor]; [myBackButton addTarget:self action:@selector(backButtonPressed:) forControlEvents:UIControlEventTouchUpInside]; [myButtonView addSubview:myBackButton]; // Some code... } In the child class: - (void)loadView { [super loadView]; //Some code .. CGRect buttonViewRect = myButtonView.frame; buttonViewRect.origin.y = yOffset; // This is basically original yOffset + 50 [myButtonView setFrame:buttonViewRect]; yOffset += KButtonViewHeight; // Add some other view below myButtonView .. }

    Read the article

  • Reason why UIImage gives me a 'distorted' image sometimes

    - by Cedric Vandendriessche
    I have a custom UIView with a UILabel and a UIImageView subview. (tried using UIImageView subclass aswell). I assign an image to it and add the view to the screen. I wrote a function which adds the amount of LetterBoxes to the screen (my custom class): - (void)drawBoxesForWord:(NSString *)word { if(boxesContainer == nil) { /* Create a container for the LetterBoxes (animation purposes) */ boxesContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 205, 320, 50)]; [self.view addSubview:boxesContainer]; } /* Calculate width of letterboxes */ NSInteger numberOfCharacters = [word length]; CGFloat totalWidth = numberOfCharacters * 28 + (numberOfCharacters - 1) * 3; CGFloat leftCap = (320 - totalWidth) / 2; [letters removeAllObjects]; /* Draw the boxes to the screen */ for (int i = 0; i < numberOfCharacters; i++) { LetterBox *letter = [[LetterBox alloc] initWithFrame:CGRectMake(leftCap + i * 31 , 0, 28, 40)]; [letters addObject:letter]; [boxesContainer addSubview:letter]; [letter release]; }} This gives me the image below: http://www.imgdumper.nl/uploads2/4ba3b2c72bb99/4ba3b2c72abfd-Goed.png But sometimes it gives me this: imgdumper.nl/uploads2/4ba3b2d888226/4ba3b2d88728a-Fout.png I add them to the same boxesContainer but they first remove themselves from the superview, so it's not like you see them double or something. What I find weird is that they are all good or all bad.. This is the init function for my LetterBox: if (self == [super initWithFrame:aRect]) { /* Create the box image with same frame */ boxImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; boxImage.contentMode = UIViewContentModeScaleAspectFit; boxImage.image = [UIImage imageNamed:@"SpaceOpen.png"]; [self addSubview:boxImage]; /* Create the label with same frame */ letterLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)]; letterLabel.backgroundColor = [UIColor clearColor]; letterLabel.font = [UIFont fontWithName:@"ArialRoundedMTBold" size:26]; letterLabel.textColor = [UIColor blackColor]; letterLabel.textAlignment = UITextAlignmentCenter; [self addSubview:letterLabel]; } return self;} Does anyone have an idea why this could be? I'd rather have them display correctly every time :)

    Read the article

  • Animating the offset of the scrollView in a UICollectionView/UITableView causes prematurely disappearing cells

    - by radutzan
    We have a UICollectionView with a custom layout very similar to UITableView (it scrolls vertically). The UICollectionView displays only 3 cells simultaneously, with one of them being the currently active cell: [ 1 ] [*2*] [ 3 ] (The active cell here is #2.) The cells are roughly 280 points high, so only the active cell is fully visible on the screen. The user doesn't directly scroll the view to navigate, instead, she swipes the active cell horizontally to advance to the next cell. We then do some fancy animations and scroll the UICollectionView so the next cell is in the "active" position, thus making it the active one, moving the old one away and bringing up the next cell in the queue: [ 2 ] [*3*] [ 4 ] The problem here is setting the UICollectionView's offset. We currently set it in a UIView animation block (self.collectionView.contentOffset = targetOffset;) along with three other animating properties, which mostly works great, but causes the first cell (the previously active one, in the latter case, #2) to vanish as soon as the animation starts running, even before the delay interval completes. This is definitely not ideal. I've thought of some solutions, but can't figure out the best one: Absurdly enlarge the UICollectionView's frame to fit five cells instead of three, thus forcing it to keep the cells in memory even if they are offscreen. I've tried this and it works, but it sounds like an awfully dirty hack. Take a snapshot of the rendered content of the vanishing cell, put it in a UIImageView, add the UIImageView as a subview of the scrollView just before the cell goes away in the exact same position of the old cell, removing it once the animation ends. Sounds less sucky than the previous option (memory-wise, at least), but still kinda hacky. I also don't know the best way to accomplish this, please point me in the right direction. Switch to UIScrollView's setContentOffset:animated:. We actually used to have this, and it fixed the disappearing cell issue, but running this in parallel with the other UIView animations apparently competes for the attention of the main thread, thus creating a terribly choppy animation on single-core devices (iPhone 3GS/4). It also doesn't allow us to change the duration or easing of the animation, so it feels out of sync with the rest. Still an option if we can find a way to make it work in harmony with the UIView block animations. Switch to UICollectionView's scrollToItemAtIndexPath:atScrollPosition:animated:. Haven't tried this, but it has a big downside: it only takes 3 possible constants (that apply to this case, at least) for the target scroll position: UICollectionViewScrollPositionTop, UICollectionViewScrollPositionCenteredVertically and UICollectionViewScrollPositionBottom. The active cell could vary its height, but it always has to be 35 points from the top of the window, and these options don't provide enough control to accomplish the design. It could also potentially be just as problematic as 3.1. Still an option because there might be a way to go around the scroll position thing that I don't know of, and it might not have the same issue with the main thread, which seems unlikely. Any help will be greatly appreciated. Please ask if you need clarification. Thanks a lot!

    Read the article

  • Multi-level navigation controller on left-hand side of UISplitView with a small twist.

    - by user141146
    Hi. I'm trying make something similar to (but not exactly like) the email app found on the iPad. Specifically, I'd like to create a tab-based app, but each tab would present the user with a different UISplitView. Each UISplitView contains a Master and a Detail view (obviously). In each UISplitView I would like the Master to be a multi-level navigational controller where new UIViewControllers are pushed onto (or popped off of) the stack. This type of navigation within the UISplitView is where the application is similar to the native email app. To the best of my knowledge, the only place that has described a decent "splitviewcontroller inside of a uitabbarcontroller" is here: http://stackoverflow.com/questions/2475139/uisplitviewcontroller-in-a-tabbar-uitabbarcontroller and I've tried to follow the accepted answer. The accepted solution seems to work for me (i.e., I get a tab-bar controller that allows me to switch between different UISplitViews). The problem is that I don't know how to make the left-hand side of the UISplitView to be a multi-level navigation controller. Here is the code I used within my app delegate to create the initial "split view 'inside' of a tab bar controller" (it's pretty much as suggested in the aforementioned link). - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSMutableArray *tabArray = [NSMutableArray array]; NSMutableArray *array = [NSMutableArray array]; UISplitViewController *splitViewController = [[UISplitViewController alloc] init]; MainViewController *viewCont = [[MainViewController alloc] initWithNibName:@"MainViewController" bundle:nil]; [array addObject:viewCont]; [viewCont release]; viewCont = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; [array addObject:viewCont]; [viewCont release]; [splitViewController setViewControllers:array]; [tabArray addObject:splitViewController]; [splitViewController release]; array = [NSMutableArray array]; splitViewController = [[UISplitViewController alloc] init]; viewCont = [[Master2 alloc] initWithNibName:@"Master2" bundle:nil]; [array addObject:viewCont]; [viewCont release]; viewCont = [[Slave2 alloc] initWithNibName:@"Slave2" bundle:nil]; [array addObject:viewCont]; [viewCont release]; [splitViewController setViewControllers:array]; [tabArray addObject:splitViewController]; [splitViewController release]; // Add the tab bar controller's current view as a subview of the window [tabBarController setViewControllers:tabArray]; [window addSubview:tabBarController.view]; [window makeKeyAndVisible]; return YES; } the class MainViewController is a UIViewController that contains the following method: - (IBAction)push_me:(id)sender { M2 *m2 = [[[M2 alloc] initWithNibName:@"M2" bundle:nil] autorelease]; [self.navigationController pushViewController:m2 animated:YES]; } this method is attached (via interface builder) to a UIButton found within MainViewController.xib Obviously, the method above (push_me) is supposed to create a second UIViewController (called m2) and push m2 into view on the left-side of the split-view when the UIButton is pressed. And yet it does nothing when the button is pressed (even though I can tell that the method is called). Thoughts on where I'm going wrong? TIA!

    Read the article

  • iPhone/Obj-C: Accessing a UIScrollView from a View displayed within it.

    - by Daniel I-S
    I'm writing a simple iPhone app which lets a user access a series of calculators. It consists of the following: UITableViewController (RootViewController), with the list of calculators. UIViewController + UIScrollView (UniversalScroller), which represents an empty scroll view - and has a 'displayedViewController' property. UIViewController (Calculators 1-9), each of which contains a view with controls that represents a particular calculator. Each calculator takes 3-5 values via UITextFields and UISliders, and has a 'calculate' button. They can potentially be taller than 460px(iPhone screen height). The idea is: User taps on a particular menu item in the RootViewController. This loads and inits UniversalScroller, ALSO loads and inits the UIViewcontroller for the particular calculator that was selected, sets the displayedViewController property of UniversalScroller to the newly loaded calculator UIViewcontroller, and pushes the UniversalScroller to the front. When the UniversalScroller hits its 'viewDidLoad' event, it sets its contentSize to the view frame size of its 'displayedViewController' object. It then adds the displayedViewController's view as a subview to itself, and sets its own title to equal that of the displayedViewController. It now displays the calculator, along with the correct title, in a scrollable form. Conceptually (and currently; this stuff has all been implemented already), this works great - I can design the calculators how I see fit, as tall as they end up being, and they will automatically be accommodated and displayed in an appropriately configured UIScrollView. However, there is one problem: The main reason I wanted to display things in a UIScrollView was so that, when the on-screen-keyboard appeared, I could shift the view up to focus on the control that is currently being edited. To do this, I need access to the UniversalScroller object that is holding the current calculator's view. On the beganEditing: event of each control, I intended to use the [UniversalScroller.view scrollRectToVisible: animated:] method to move focus to the correct control. However, I am having trouble accessing the UniversalScroller. I tried assigning a reference to it as a property of each calculator UIViewController, but did't seem to have much luck. I've read about using Delegates but have had trouble working out exactly how they work. I'm looking for one of three things: Some explanation of how I can access the methods of a UIScrollView from a UIViewController whose view is contained within it. or Confirmation of my suspicions that making users scroll on a data entry form is bad, and I should just abandon scrollviews altogether and move the view up and down to the relevant position when the keyboard appears, then back when it disappears. or Some pointers on how I could go about redesigning the calculators (which are basically simple data entry forms using labels, sliders and textfields) to be contained within UITableViewCells (presumably in a UITableView, which I understand is a scrollview deep down) - I read a post on SO saying that that's a more pleasing way to make a data entry form, but I couldn't find any examples of that online. Screenshots would be nice. Anything to make my app more usable and naturally 'iPhone-like', since shuffling labels and textboxes around makes me feel like I am building a winforms app! I've only recently started with this platform and language, and despite being largely an Apple skeptic I definitely see the beauty in the way that it works. Help me solve this problem and I might fall in love completely. Dan

    Read the article

  • Advance way of using UIView convertRect method to detect CGRectIntersectsRect multiple times

    - by Chris
    I recently asked a question regarding collision detection within subviews, with a perfect answer. I've come to the last point in implementing the collision on my application but I've come across a new issue. Using convertRect was fine getting the CGRect from the subView. I needed it to be a little more complex as it wasn't exactly rectangles that needed to be detected. on XCode I created an abstract class called TileViewController. Amongst other properties it has a IBOutlet UIView *detectionView; I now have multiple classes that inherit from TileViewController, and each class there are multiple views nested inside the detectionView which I have created using Interface Builder. The idea is an object could be a certain shape or size, I've programatically placed these 'tiled' detection points bottom center of each object. A user can select an item and interactive with it, in this circumstance move it around. Here is my touchesMoved method -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [[event allTouches] anyObject]; CGPoint location = [touch locationInView:touch.view]; interactiveItem.center = location; // The ViewController the user has chosen to interact with interactiveView.view.center = location; // checks if the user has selected an item to interact with if (interactiveItem) { // First get check there is more then 1 item in the collection NSUInteger assetCount = [itemViewCollection count]; //NSMutableArray that holds the ViewControllers int detectionCount = 0; // To count how many times a CGRectIntersectsRect occured UIView *parentView = self.view; // if there is more then 1 item begin collision detection if (assetCount > 1) { for (TileViewController *viewController in itemViewCollection) { if (viewController.view.tag != interactiveView.view.tag) { if (viewController.detectionView.subviews) { for (UIView *detectView in viewController.detectionView.subviews) { CGRect viewRect; viewRect = [detectView convertRect:[detectView frame] toView:parentView]; // I could have checked to see if the below has subViews but didn't - In my current implementation it does anyway for (UIView *detectInteractView in interactiveView.detectionView.subviews) { CGRect interactRect; interactRect = [detectInteractView convertRect:[detectInteractView frame] toView:parentView]; if (CGRectIntersectsRect(viewRect, interactRect) == 1) { NSLog(@"collision detected"); [detectView setBackgroundColor:[UIColor blueColor]]; [detectInteractView setBackgroundColor:[UIColor blueColor]]; detectionCount++; } else { [detectView setBackgroundColor:[UIColor yellowColor]]; [detectInteractView setBackgroundColor:[UIColor yellowColor]]; } } } } } } // Logic if no items collided if (detectionCount == 0) { NSLog(@"Do something"); } } } } Now the method itself works to an extent but I don't think it's working with the nested values properly as the detection is off. A simplified version of this method works - Using CGRectIntersectsRect on the detectionView itself so I'm wondering if I'm looping through and checking the views correctly? I wasn't sure whether it was comparing in the same view but I suspect it is, I did modify the code slightly at one point, rather then comparing the values in self.view I took the viewController.detectView's UIViews into the interactiveView.detectView but the outcome was the same. It's rigged so the subviews change colour, but they change colour when they are not even touching, and when they do touch the wrong UIviews are changing colour Many thanks in advance

    Read the article

  • How to create a Facebook-App style notifications custom table?

    - by Tim Büthe
    I want to add a custom table to my iPhone app, that should look and work like the one used in the facebook app showing the notifications. It should contain rows with links in it. The text should be black, while the tap-able parts should appear blue. As a already figured out, labels only have one font, color and so on and you can't mix styles within it, I would have to use different components. The tab-able text parts maybe UIButtons with custom style without any border. I tried different approches to build the custom cell. I used Interface Builder, to layout components, but since the different parts have variable lengths they overlaid each other. I also tried to add instances of UIButton and UILabel as a subview to the cell's contentView as descibed in Apple's tutorial. The problem with this is that: The position and size of the components is fix and set when they get created using "initWithFrame:...". My code in "tableView:cellForRowAtIndexPath:" looks like this: UIButton *usernameButton; UILabel *mainLabel, *secondLabel; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { // cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0.0, 0.0, 220.0, 60.0) reuseIdentifier:CellIdentifier] autorelease]; [cell setBackgroundColor: [UIColor yellowColor]]; usernameButton = [[[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 220.0, 15.0)] autorelease]; usernameButton.tag = USERNAME_BUTTON_TAG; // ... format, font etc. usernameButton.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:usernameButton]; mainLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 20.0, 220.0, 15.0)] autorelease]; mainLabel.tag = MAINLABEL_TAG; // ... format, font etc. mainLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:mainLabel]; secondLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 40.0, 220.0, 15.0)] autorelease]; secondLabel.tag = SECONDLABEL_TAG; // ... format, font etc. secondLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleHeight; [cell.contentView addSubview:secondLabel]; } else { usernameButton = (UIButton *) [cell.contentView viewWithTag:USERNAME_BUTTON_TAG]; mainLabel = (UILabel *)[cell.contentView viewWithTag:MAINLABEL_TAG]; secondLabel = (UILabel *)[cell.contentView viewWithTag:SECONDLABEL_TAG]; } usernameButton.titleLabel.text = @"Peter"; mainLabel.text = @"sent you a message: ..."; secondLabel.text = @"11 minutes ago"; return cell; In a nutshell, I want to add the labels and buttons without a fix position or size, the buttons clickable and the cell height should automatically set according to the content. Here is an example of the cell's content: Peter sent you a message: "Hello! What are you doing?" Peter should be click/tab-able and his message, which has a variable length, should be italic and wrapped if necessary.

    Read the article

  • UIPageControl bug: showing one bullet first and then showing everything

    - by user313551
    I have some strange behavior using a UIPageControl: First it appears showing only one bullet, then when I move the scroll view all the bullets appear correctly. Is there something I'm missing before I add it as a subview? Here is my code imageScrollView.h : @interface ImageScrollView : UIView <UIScrollViewDelegate> { NSMutableDictionary *photos; BOOL *pageControlIsChangingPage; UIPageControl *pageControl; } @property (nonatomic, copy) NSMutableDictionary *photos; @property (nonatomic, copy) UIPageControl *pageControl; @end Here is the code for imageScrollView.m: #import "ImageScrollView.h" @implementation ImageScrollView @synthesize photos, pageControl; - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Initialization code NSLog(@"%@",pageControl); } return self; } - (void) drawRect:(CGRect)rect { [self removeAllSubviews]; UIScrollView *scroller = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,self.frame.size.width,self.frame.size.height)]; [scroller setDelegate:self]; [scroller setBackgroundColor:[UIColor grayColor]]; [scroller setShowsHorizontalScrollIndicator:NO]; [scroller setPagingEnabled:YES]; NSUInteger nimages = 0; CGFloat cx= 0; for (NSDictionary *myDictionaryObject in photos) { if (![myDictionaryObject isKindOfClass:[NSNull class]]) { NSString *photo =[NSString stringWithFormat:@"http://www.techbase.com.mx/blog/%@", [myDictionaryObject objectForKey:@"filepath"]]; NSDictionary *data = [myDictionaryObject objectForKey:@"data"]; UIView *imageContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)]; TTImageView *imageView = [[TTImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height - 30)]; imageView.urlPath=photo; [imageContainer addSubview:imageView]; UILabel *caption = [[UILabel alloc] initWithFrame:CGRectMake(0,imageView.frame.size.height,imageView.frame.size.width,10)]; [caption setText:[NSString stringWithFormat:@"%@",[data objectForKey:@"description"]]]; [caption setBackgroundColor:[UIColor grayColor]]; [caption setTextColor:[UIColor whiteColor]]; [caption setLineBreakMode:UILineBreakModeWordWrap]; [caption setNumberOfLines:0]; [caption sizeToFit]; [caption setFont:[UIFont fontWithName:@"Georgia" size:10.0]]; [imageContainer addSubview:caption]; CGRect rect = imageContainer.frame; rect.size.height = imageContainer.size.height; rect.size.width = imageContainer.size.width; rect.origin.x = ((scroller.frame.size.width - scroller.size.width) / 2) + cx; rect.origin.y = ((scroller.frame.size.height - scroller.size.height) / 2); imageContainer.frame=rect; [scroller addSubview:imageContainer]; [imageView release]; [imageContainer release]; [caption release]; nimages++; cx +=scroller.frame.size.width; } } [scroller setContentSize:CGSizeMake(nimages * self.frame.size.width, self.frame.size.height)]; [self addSubview:scroller]; pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(self.frame.size.width/2, self.frame.size.height -20, (self.frame.size.width/nimages)/2, 20)]; pageControl.numberOfPages=nimages; [self addSubview:pageControl]; [scroller release]; } -(void)dealloc { [pageControl release]; [super dealloc]; } -(void)scrollViewDidScroll:(UIScrollView *)_scrollView{ if(pageControlIsChangingPage){ return; } CGFloat pageWidth = _scrollView.frame.size.width; int page = floor((_scrollView.contentOffset.x - pageWidth /2) / pageWidth) + 1; pageControl.currentPage = page; } -(void)scrollViewDidEndDecelerating:(UIScrollView *)_scrollView{ pageControlIsChangingPage = NO; } @end

    Read the article

  • objective-c Novice - Needs help with global variables and setter method

    - by user544006
    I am creating a quiz app which has 2 views, MMAppViewController and a subview Level1View. I have declared NSInteger property "theScore" in the MMAppViewController view and have synthesised it. In my Level1View when they answer a correct question the "theScore" int will increase by one. The score has to be a global variable because when you reach so many points it will unlock the next level. For some reason in my switch statement it only lets me use the setTheScore method once. I am getting errors for every other set method in the switch statement. Error: "Duplicate label setTheScore". The statement is in the pushButtonAnswer method: setTheScore: theScore++; Here is my code: #import "Level1View.h" #import "MMAppViewController.h" @implementation Level1View @synthesize answer; @synthesize question; @synthesize userAnswer; @synthesize theScore; @synthesize score; int questionNum=0; NSInteger score=0; NSInteger theScore; BOOL start=FALSE; BOOL optionNum=FALSE; -(IBAction)pushBack{ [self dismissModalViewControllerAnimated:YES]; } -(IBAction)pushButton1{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"1"; [labelAnswer setText:(@"You chose 'A'")]; } -(IBAction)pushButton2{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"2"; [labelAnswer setText:(@"You chose 'B'")]; } -(IBAction)pushButton3{ optionNum=TRUE; labelAnswer.textColor=[UIColor blackColor]; userAnswer=@"3"; [labelAnswer setText:(@"You chose 'C'")]; } -(IBAction)pushButtonAnswer{ labelAnswer.textColor=[UIColor blackColor]; switch (questionNum){ case 1: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; [labelAnswer setText:(@"correct")]; [self hideButtons]; score++; [self setTheScore: theScore++]; } else if(optionNum==FALSE){ [labelAnswer setText:(@"Please choose an answer below:")];} else{ labelAnswer.textColor=[UIColor redColor]; [labelAnswer setText:(@"wrong")];} [self hideButtons]; break; case 2: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; [labelAnswer setText:(@"correct")]; [self hideButtons]; score++; [self setTheScore: theScore++]; } else if(optionNum==FALSE){ [labelAnswer setText:(@"Please choose an answer below:")];} else{ labelAnswer.textColor=[UIColor redColor]; [labelAnswer setText:(@"wrong")]; [self hideButtons];} break; case 3: if(answer==userAnswer && optionNum==TRUE){ labelAnswer.textColor=[UIColor greenColor]; .... And #import "MMAppViewController.h" #import "Level1View.h" @implementation MMAppViewController @synthesize theScore; NSInteger score; -(IBAction)pushLevel1{ Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil]; [self presentModalViewController:level1View animated:YES]; theScore++; } -(IBAction)pushLevel2{ //Level1View *level1View = [[Level1View alloc] initWithNibName:nil bundle:nil]; //[self presentModalViewController:level1View animated:YES]; NSInteger *temp = Level1View.score; //int theScore=2; [labelChoose setText:[NSString stringWithFormat:@"You scored %i", theScore]]; } Does anyone know why i am getting these errors and if I am coding this correctly?

    Read the article

  • Help with force close occurrences in my app

    - by Ken
    This is the last issue with this app. Periodic force close situations. I think something should be on another thread but I'm not sure what. Anyway, I can always count on a freeze on first install. If I wait, eventually (maybe 10 seconds) the app comes around, maybe more. here is an excerpt from logcat--the three lines occur after full layout is displayed and I attempt to touch a [game] 'peg' which should spawn a sprite, but the freeze occurs there. Can anybody tell what the issue might be?: I/System.out( 279): TouchDown (17.0,106.0) I/System.out( 279): checking (17,106 I/System.out( 279): hit for bounds Rect(3, 98 - 32, 130) [FREEZE BEGINS] W/webcore ( 279): Can't get the viewWidth after the first layout W/WindowManager( 60): Key dispatching timed out sending to com.live.brainbuilderfree/com.live.brainbuilderfree.BrainBuilderFree W/WindowManager( 60): Previous dispatch state: null W/WindowManager( 60): Current dispatch state: {{null to Window{43fd87a0 com.live.brainbuilderfree/com.live.brainbuilderfree.BrainBuilderFree paused=false} @ 1295232880017 lw=Window{43fd87a0 com.live.brainbuilderfree/com.live.brainbuilderfree.BrainBuilderFree paused=false} lb=android.os.BinderProxy@440523b8 fin=false gfw=true ed=true tts=0 wf=false fp=false mcf=Window{43fd87a0 com.live.brainbuilderfree/com.live.brainbuilderfree.BrainBuilderFree paused=false}}} I/Process ( 60): Sending signal. PID: 279 SIG: 3 I/dalvikvm( 279): threadid=3: reacting to signal 3 D/dalvikvm( 124): GC_EXPLICIT freed 1754 objects / 106104 bytes in 7365ms I/Process ( 60): Sending signal. PID: 60 SIG: 3 I/dalvikvm( 60): threadid=3: reacting to signal 3 I/dalvikvm( 60): Wrote stack traces to '/data/anr/traces.txt' I/Process ( 60): Sending signal. PID: 263 SIG: 3 I/dalvikvm( 263): threadid=3: reacting to signal 3 I/dalvikvm( 279): Wrote stack traces to '/data/anr/traces.txt' I/Process ( 60): Sending signal. PID: 117 SIG: 3 I/dalvikvm( 117): threadid=3: reacting to signal 3 I/dalvikvm( 117): Wrote stack traces to '/data/anr/traces.txt' I/Process ( 60): Sending signal. PID: 254 SIG: 3 I/Process ( 60): Sending signal. PID: 121 SIG: 3 I/dalvikvm( 121): threadid=3: reacting to signal 3 D/AudioSink( 34): bufferCount (4) is too small and increased to 12 I/System.out( 279): making white sprite I/Process ( 60): Sending signal. PID: 186 SIG: 3 I/Process ( 60): Sending signal. PID: 232 SIG: 3 D/MillennialMediaAdSDK( 279): size: 1 D/MillennialMediaAdSDK( 279): num: 1 D/AdWhirl SDK( 279): Millennial success D/AdWhirl SDK( 279): Will call rotateAd() in 120 seconds I/dalvikvm( 232): threadid=3: reacting to signal 3 I/dalvikvm( 121): Wrote stack traces to '/data/anr/traces.txt' I/Process ( 60): Sending signal. PID: 222 SIG: 3 I/MillennialMediaAdSDK( 279): Millennial ad return success D/MillennialMediaAdSDK( 279): View height: 0 D/MillennialMediaAdSDK( 279): nextUrl: [deleted] I/Process ( 60): Sending signal. PID: 239 SIG: 3 I/Process ( 60): Sending signal. PID: 213 SIG: 3 D/AdWhirl SDK( 279): Added subview D/AdWhirl SDK( 279): Pinging URL: [deleted] I/Process ( 60): Sending signal. PID: 197 SIG: 3 I/dalvikvm( 197): threadid=3: reacting to signal 3 I/Process ( 60): Sending signal. PID: 164 SIG: 3 I/dalvikvm( 164): threadid=3: reacting to signal 3 D/dalvikvm( 279): GC_FOR_MALLOC freed 7735 objects / 639688 bytes in 217ms I/Process ( 60): Sending signal. PID: 124 SIG: 3 I/dalvikvm( 124): threadid=3: reacting to signal 3 I/Process ( 60): Sending signal. PID: 158 SIG: 3 I/dalvikvm( 158): threadid=3: reacting to signal 3 I/Process ( 60): Sending signal. PID: 127 SIG: 3 E/ActivityManager( 60): ANR in com.live.brainbuilderfree (com.live.brainbuilderfree/.BrainBuilderFree) E/ActivityManager( 60): Reason: keyDispatchingTimedOut E/ActivityManager( 60): Load: 3.46 / 1.69 / 0.65 E/ActivityManager( 60): CPU usage from 28095ms to 140ms ago: E/ActivityManager( 60): system_server: 30% = 25% user + 4% kernel / faults: 3119 minor 66 major E/ActivityManager( 60): mediaserver: 11% = 7% user + 4% kernel / faults: 746 minor 17 major E/ActivityManager( 60): com.svox.pico: 1% = 0% user + 1% kernel / faults: 2833 minor 8 major E/ActivityManager( 60): d.process.acore: 1% = 0% user + 0% kernel / faults: 1146 minor 36 major E/ActivityManager( 60): ndroid.launcher: 1% = 0% user + 0% kernel / faults: 852 minor 6 major E/ActivityManager( 60): m.android.phone: 0% = 0% user + 0% kernel / faults: 621 minor 7 major E/ActivityManager( 60): kswapd0: 0% = 0% user + 0% kernel E/ActivityManager( 60): ronsoft.openwnn: 0% = 0% user + 0% kernel / faults: 337 minor 2 major E/ActivityManager( 60): adbd: 0% = 0% user + 0% kernel / faults: 3 minor E/ActivityManager( 60): zygote: 0% = 0% user + 0% kernel / faults: 169 minor E/ActivityManager( 60): events/0: 0% = 0% user + 0% kernel E/ActivityManager( 60): rild: 0% = 0% user + 0% kernel / faults: 103 minor 3 major E/ActivityManager( 60): pdflush: 0% = 0% user + 0% kernel E/ActivityManager( 60): .quicksearchbox: 0% = 0% user + 0% kernel / faults: 61 minor E/ActivityManager( 60): id.defcontainer: 0% = 0% user + 0% kernel / faults: 12 minor E/ActivityManager( 60): +rainbuilderfree: 0% = 0% user + 0% kernel E/ActivityManager( 60): +sh: 0% = 0% user + 0% kernel E/ActivityManager( 60): +app_process: 0% = 0% user + 0% kernel E/ActivityManager( 60): TOTAL: 100% = 76% user + 21% kernel + 2% iowait + 0% irq + 0% softirq I/dalvikvm( 127): threadid=3: reacting to signal 3 I/dalvikvm( 186): threadid=3: reacting to signal 3 D/dalvikvm( 60): GC_FOR_MALLOC freed 3747 objects / 228920 bytes in 609ms I/dalvikvm-heap( 60): Grow heap (frag case) to 4.759MB for 36896-byte allocation I/dalvikvm( 239): threadid=3: reacting to signal 3 D/dalvikvm( 60): GC_FOR_MALLOC freed 226 objects / 9952 bytes in 546ms I/dalvikvm( 213): threadid=3: reacting to signal 3 D/dalvikvm( 60): GC_FOR_MALLOC freed 105 objects / 5816 bytes in 492ms I/dalvikvm-heap( 60): Grow heap (frag case) to 4.815MB for 49188-byte allocation I/dalvikvm( 222): threadid=3: reacting to signal 3 D/dalvikvm( 60): GC_FOR_MALLOC freed 77 objects / 5232 bytes in 546ms I/dalvikvm( 254): threadid=3: reacting to signal 3 D/dalvikvm( 60): GC_FOR_MALLOC freed 105 objects / 55856 bytes in 521ms I/dalvikvm-heap( 60): Grow heap (frag case) to 4.876MB for 98360-byte allocation D/dalvikvm( 60): GC_FOR_MALLOC freed 58 objects / 3632 bytes in 340ms D/dalvikvm( 60): GC_FOR_MALLOC freed 1093 objects / 185256 bytes in 572ms W/WindowManager( 60): Continuing to wait for key to be dispatched I/System.out( 279): TouchMove (117.0,124.0) I/System.out( 279): TouchUP (117.0,124.0) D/dalvikvm( 60): GC_FOR_MALLOC freed 141 objects / 108328 bytes in 564ms I/ARMAssembler( 60): generated scanline__00000077:03515104_00000000_00000000 [ 33 ipp] (47 ins) at [0x313d78:0x313e34] in 11621593 ns W/InputManagerService( 60): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43f66a10 I/dalvikvm( 239): Wrote stack traces to '/data/anr/traces.txt' I/dalvikvm( 263): Wrote stack traces to '/data/anr/traces.txt' etc...

    Read the article

  • Add UIView and UILabel to UICollectionViewCell. Then Segue based on clicked cell index

    - by JetSet
    I am new to collection views in Objective-C. Can anyone tell me why I can't see my UILabel embedded in the transparent UIView and the best way to resolve. I want to also segue from the cell to several various UIViewControllers based on the selected index cell. I am using GitHub project https://github.com/mayuur/MJParallaxCollectionView Overall, in MJRootViewController.m I wanted to add a UIView with a transparency and a UILabel with details of the cell from a array. MJCollectionViewCell.h // MJCollectionViewCell.h // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import <UIKit/UIKit.h> #define IMAGE_HEIGHT 200 #define IMAGE_OFFSET_SPEED 25 @interface MJCollectionViewCell : UICollectionViewCell /* image used in the cell which will be having the parallax effect */ @property (nonatomic, strong, readwrite) UIImage *image; /* Image will always animate according to the imageOffset provided. Higher the value means higher offset for the image */ @property (nonatomic, assign, readwrite) CGPoint imageOffset; //@property (nonatomic,readwrite) UILabel *textLabel; @property (weak, nonatomic) IBOutlet UILabel *textLabel; @property (nonatomic,readwrite) NSString *text; @property(nonatomic,readwrite) CGFloat x,y,width,height; @property (nonatomic,readwrite) NSInteger lineSpacing; @property (nonatomic, strong) IBOutlet UIView* overlayView; @end MJCollectionViewCell.m // // MJCollectionViewCell.m // RCCPeakableImageSample // // Created by Mayur on 4/1/14. // Copyright (c) 2014 RCCBox. All rights reserved. // #import "MJCollectionViewCell.h" @interface MJCollectionViewCell() @property (nonatomic, strong, readwrite) UIImageView *MJImageView; @end @implementation MJCollectionViewCell - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) [self setupImageView]; return self; } - (id)initWithCoder:(NSCoder *)aDecoder { self = [super initWithCoder:aDecoder]; if (self) [self setupImageView]; return self; } /* // Only override drawRect: if you perform custom drawing. // An empty implementation adversely affects performance during animation. - (void)drawRect:(CGRect)rect { // Drawing code } */ #pragma mark - Setup Method - (void)setupImageView { // Clip subviews self.clipsToBounds = YES; // Add image subview self.MJImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, IMAGE_HEIGHT)]; self.MJImageView.backgroundColor = [UIColor redColor]; self.MJImageView.contentMode = UIViewContentModeScaleAspectFill; self.MJImageView.clipsToBounds = NO; [self addSubview:self.MJImageView]; } # pragma mark - Setters - (void)setImage:(UIImage *)image { // Store image self.MJImageView.image = image; // Update padding [self setImageOffset:self.imageOffset]; } - (void)setImageOffset:(CGPoint)imageOffset { // Store padding value _imageOffset = imageOffset; // Grow image view CGRect frame = self.MJImageView.bounds; CGRect offsetFrame = CGRectOffset(frame, _imageOffset.x, _imageOffset.y); self.MJImageView.frame = offsetFrame; } - (void)setText:(NSString *)text{ _text=text; if (!self.textLabel) { CGFloat realH=self.height*2/3-self.lineSpacing; CGFloat latoA=realH/3; // self.textLabel=[[UILabel alloc] initWithFrame:CGRectMake(10,latoA/2, self.width-20, realH)]; self.textLabel.layer.anchorPoint=CGPointMake(.5, .5); self.textLabel.font=[UIFont fontWithName:@"HelveticaNeue-ultralight" size:38]; self.textLabel.numberOfLines=3; self.textLabel.textColor=[UIColor whiteColor]; self.textLabel.shadowColor=[UIColor blackColor]; self.textLabel.shadowOffset=CGSizeMake(1, 1); self.textLabel.transform=CGAffineTransformMakeRotation(-(asin(latoA/(sqrt(self.width*self.width+latoA*latoA))))); [self addSubview:self.textLabel]; } self.textLabel.text=text; } @end MJViewController.h // // MJViewController.h // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import <UIKit/UIKit.h> @interface MJRootViewController : UIViewController{ NSInteger choosed; } @end MJViewController.m // // MJViewController.m // ParallaxImages // // Created by Mayur on 4/1/14. // Copyright (c) 2014 sky. All rights reserved. // #import "MJRootViewController.h" #import "MJCollectionViewCell.h" @interface MJRootViewController () <UICollectionViewDataSource, UICollectionViewDelegate, UIScrollViewDelegate> @property (weak, nonatomic) IBOutlet UICollectionView *parallaxCollectionView; @property (nonatomic, strong) NSMutableArray* images; @end @implementation MJRootViewController - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //self.navigationController.navigationBarHidden=YES; // Fill image array with images NSUInteger index; for (index = 0; index < 14; ++index) { // Setup image name NSString *name = [NSString stringWithFormat:@"image%03ld.jpg", (unsigned long)index]; if(!self.images) self.images = [NSMutableArray arrayWithCapacity:0]; [self.images addObject:name]; } [self.parallaxCollectionView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - UICollectionViewDatasource Methods - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return self.images.count; } - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { MJCollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"MJCell" forIndexPath:indexPath]; //get image name and assign NSString* imageName = [self.images objectAtIndex:indexPath.item]; cell.image = [UIImage imageNamed:imageName]; //set offset accordingly CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - cell.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; cell.imageOffset = CGPointMake(0.0f, yOffset); NSString *text; NSInteger index=choosed>=0 ? choosed : indexPath.row%5; switch (index) { case 0: text=@"I am the home cell..."; break; case 1: text=@"I am next..."; break; case 2: text=@"Cell 3..."; break; case 3: text=@"Cell 4..."; break; case 4: text=@"The last cell"; break; default: break; } cell.text=text; cell.overlayView.backgroundColor = [UIColor colorWithWhite:0.0f alpha:0.4f]; //cell.textLabel.text = @"Label showing"; cell.textLabel.font = [UIFont boldSystemFontOfSize:22.0f]; cell.textLabel.textColor = [UIColor whiteColor]; //This is another attempt to display the label by using tags. //UILabel* label = (UILabel*)[cell viewWithTag:1]; //label.text = @"Label works"; return cell; } #pragma mark - UIScrollViewdelegate methods - (void)scrollViewDidScroll:(UIScrollView *)scrollView { for(MJCollectionViewCell *view in self.parallaxCollectionView.visibleCells) { CGFloat yOffset = ((self.parallaxCollectionView.contentOffset.y - view.frame.origin.y) / IMAGE_HEIGHT) * IMAGE_OFFSET_SPEED; view.imageOffset = CGPointMake(0.0f, yOffset); } } @end

    Read the article

< Previous Page | 11 12 13 14 15