Search Results

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

Page 6/15 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • Passing touch events on to subviews

    - by Egil Jansson
    I have a view within a UIScrollView that loads an additional subview when the user presses a certain area. When this additional subview is visible, I want all touch events to be handled by this - and not by the scrollview. It seems like the first couple events are being handled by the subview, but then touchesCancelled is called and the scrollview takes over the touch detection. How can I make sure that the subview gets all the events as long as the movement activity is being performed on this view? This is my implementation on touchesMoved - which I thought would do the job... -(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [[touches allObjects] objectAtIndex:0]; CGPoint touchPt = [touch locationInView:self]; UIView *hitView = [self hitTest:touchPt withEvent:event]; UIView *mySubView = subviewCtrl.view; if(hitView == mySubView) { [subviewCtrl.view touchesMoved:touches withEvent:event]; } else { NSLog(@"Outside of view..."); } }

    Read the article

  • Why isn't UIScrollView always calling viewDidLoad on subviews?

    - by Rob S.
    I'm a bit confused on the behaviour of UIScrollView as it pertains to subview loading. In my app, I lazily load subviews into my scroller. Most of the time, -viewDidLoad is called on the subview immediately after adding it the UIScrollView. There is one scenario where it isn't being called. At the 'end' of my scroll view I have a "please wait" view. When it is fully scrolled on to the page, it fades out, I add the subview and -viewDidLoad is not called. In this case, when I remove the last subview and add another subview, I get nothing. I've tried [scrollView setNeedsDisplay] and [scrollView setNeedsLayout] to no avail. I've also sent the same messages to the view I just added - no dice. Does anyone have any insight here? Many people have many questions about -viewDidLoad and I haven't been able to find one related to direct subviews inside of a scrollview. Or I have and I haven't realized it :) Thanks in advance! Rob

    Read the article

  • Is the method addSubview of NSView inherently slow? (Cocoa OSX)

    - by Michael Minerva
    I am trying to speed my gui that loads very slow slow when I am loading a large project (the gui is a representation of groups and sub groups and is made up of many views). During this process I was looking at how long certain code segments take to execute and I have found that a call to addsubview is taking between 10 and 20 milliseconds most of the time. The subview I was looking at is a disclosure button. I am wondering if this method is just inherently slow or is their some other factor at work here? Is the time it takes to add the subview dependent on the complexity of the subview or is that not a factor? Also, is there some other method that can be used to add a subview that might be faster?

    Read the article

  • Releasing the keyboard stops shake events. Why?

    - by Moshe
    1) How do I make a UITextField resign the keyboard and hide it? The keyboard is in a dynamically created subview whose superview looks for shake events. Resigning first responder seems to break the shake event handler. 2) how do you make the view holding the keyboard transparent, like see through glass? I have seen this done before. This part has been taken care of thanks guys. As always, code samples are appreciated. I've added my own to help explain the problem. EDIT: Basically, - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event; gets called in my main view controller to handle shaking. When a user taps on the "edit" icon (a pen, in the bottom of the screen - not the traditional UINavigationBar edit button), the main view adds a subview to itself and animates it on to the screen using a custom animation. This subview contains a UINavigationController which holds a UITableView. The UITableView, when a cell is tapped on, loads a subview into itself. This second subview is the culprit. For some reason, a UITextField in this second subview is causing problems. When a user taps on the view, the main view will not respond to shakes unless the UITextField is active (in editing mode?). Additional info: My Motion Event Handler: - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"%@", [event description]); SystemSoundID SoundID; NSString *soundFile = [[NSBundle mainBundle] pathForResource:@"shake" ofType:@"aif"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:soundFile], &SoundID); AudioServicesPlayAlertSound(SoundID); [self genRandom:TRUE]; } The genRandom: Method: /* Generate random label and apply it */ -(void)genRandom:(BOOL)deviceWasShaken{ if(deviceWasShaken == TRUE){ decisionText.text = [NSString stringWithFormat: (@"%@", [shakeReplies objectAtIndex:(arc4random() % [shakeReplies count])])]; }else{ SystemSoundID SoundID; NSString *soundFile = [[NSBundle mainBundle] pathForResource:@"string" ofType:@"aif"]; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:soundFile], &SoundID); AudioServicesPlayAlertSound(SoundID); decisionText.text = [NSString stringWithFormat: (@"%@", [pokeReplies objectAtIndex:(arc4random() % [pokeReplies count])])]; } } shakeReplies and pokeReplies are both NSArrays of strings. One is used for when a certain part of the screen is poked and one is for when the device is shaken. The app will randomly choose a string from the NSArray and display onscreen. For those of you who work graphically, here is a diagram of the view hierarchy: Root View -> UINavigationController -> UITableView -> Edit View -> Problem UITextfield

    Read the article

  • Iphone remove sub view

    - by Sharanya
    I have a UINavigationController. On the right top i have a button on click of which i have to get a drop down table view. I created another UIViewController Class, with xib and added it as a subView to the current view. It should appear on 1st click and disappear on the 2nd click. This should happen for all click(open view and close view). I wrote this code but dont know where i'm going wrong. someone please help -(void)modalTableView { tableView1 = [[TableViewController alloc] initWithNibName:@"TableViewController" bundle:nil]; for (UIView *subView in self.view.subviews) { if ([subView isKindOfClass:[TableViewController class]]) { [subView removeFromSuperview]; } else { [self.view addSubview:tableView1.view]; } } } What am i missing here? EDIT : TableViewController is the name of my UIViewController Class

    Read the article

  • If a NSView uses autolayout, do all of its subviews also need to use autolayout for positioning?

    - by boyfarrell
    I have a view in a window, the position and size of the view are calculated with autolayout. The view has a subview, a draggable NSView subclass. It is really easy to make a NSView "draggable" by overriding -mouseDown: and -mouseDragged: and changing the frame of the view directly. The view hierarchy is as follows, What is the best way of making the subview draggable in this case? For example, Is it possible for the subview to not use autolayout, so that it can be positioned by changing the frame directly? i.e. the window positions the main view, but then autolayout does not layout the subview inside the main view. Or to all views in the hierarchy need to use autolayout. When I have used autolayout before, I have used it to make "fixed" layout that respond to resizing. But dragging a view with a mouse does't seems like a natural use case for autolayout.

    Read the article

  • Modifying UINavigation Bar Buttons in SubViews

    - by james
    I'm having trouble trying to modify the navigation bar in the subview portion of my application. self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(add_Clicked:)] autorelease]; I have no issues modifying the navigation bar in any of my UIViewControllers classes. The simplified application class outline is as such: AppDelegate - UIViewControllerA (has a left and a right navigationBarButton) - Subview is displayed when a SegmentControl is selected. (Within the subview, I'm trying to modify the right NavigationBarButton that is displayed) [self.view addSubview:newControllerName.view]; Methods I have attempted: Trying to set self.navigationItem.rightBarButtonItem within my subview to a new UIBarButtonItem. Creating a pointer to UIViewControllerA within my AppDelegate. The UIViewControllerA contains a function setNavButton I wrote to set the rightBarButtonItem to a button. Then I am referencing the AppDelegate's reference to UIViewControllerA and attempting to call setNavButton. I included a NSLog call to see if that function is being called and it is executing but the NavigationBar isn't being modified. I'm trying to avoid having to push a UIViewController after the SegmentControl is clicked in UIViewControllerA so that I can simulate the SegmentControl as tabs. I'm not getting any errors during compile or run time. Anyone have any ideas?

    Read the article

  • How does the overall view hierarchy change when using UIKit view manipulations?

    - by executor21
    I've been trying to figure out what happens in the view hierarchy when methods like pushViewController:animated, presentModalViewController:animated, and tab switches in UITabBarViewController are used, as well as UIAlertView and UIActionSheet. (Side note: I'm doing this because I need to know whether a specific UIView of my creation is visible on screen when I do not know anything about how it or its superview may have been added to the view hierarchy. If someone knows a good way to determine this, I'd welcome the knowledge.) To figure it out, I've been logging out the hierarchy of [[UIApplication sharedApplication] keyWindow] subviews in different circumstances. Is the following correct: When a new viewController is pushed onto the stack of a UINavigationController, the old viewController's view is no longer in the view hierarchy. That is, only the top view controller's view is a subview of UINavigationController's view (according to logs, it's actually several private classes such as UILayoutContainerView). Are the views of view controllers below the top controller of the stack actually removed from the window? A very similar thing happens when a new viewController is presented via presentModalViewController:animated. The new viewController's view is the only subview of the kew window. Is this correct? The easiest thing to understand: a UIAlertView creates its own window and makes it key. The strangest thing I encountered: a UIActionSheet is shown via showInView: method, the actionSheet isn't in the view hierarchy at all. It's not a subview of the view passed as an argument to showInView:, it isn't added as a subview of the key window, and it doesn't create its own window. How does it appear, then? I haven't tried this yet, so I'd like to know what happens in the keyWindow hierarchy when tabs in a UITabBarController are switched. Is the view of the selected UIViewController moved to the top, or does it work like with pushViewController:animated and presentModalViewController:animated, where only the displayed view is in the window hierarchy?

    Read the article

  • Obtaining touch location for a uiscrollview touch

    - by LOSnively
    I have a uiscrollview as an element of a uiscrollviewcontroller, along with other view objects. The image scrolls and zooms as expected, when the scrollView is the top subview. However, I also need to get the screen location of the touch, in particular when there is no scroll action. (I understand the location may change during a scroll, but that's not important.) I haven't found a way to do that. In the scrollviewcontroller implementation I have customized all of the standard methods that should do this: "touchesShouldBegin...", "touchesBegan:...", "touchesEnded:...", and so on. As far as I can tell, none of these are being called during a touch event when the scrollView is the top subview. I've tried setting the delayContentTouches property to both YES and NO, and that doesn't seem to make a difference. As an alternative, I've tried putting a UIView as the top subview and then tried passing the touches to the now underlying scrollView. In this configuration, the standard methods are called and I can get the touch location, but I haven't found a mechanism for the touches to be passed to the scrollView so scrolling occurs. Doing something like sending the touch messages to the specific scrollView, or to "super" or just sending them to nextResponder doesn't do it. It seems I can make the scroll work or find the location of the touch but not both, depending on what the "top" subview is. I suspect this is trivial, but after two weeks of struggling, it's time to eat my embarrassment for not being able to do this seemingly simplest of things. I've read all of the related questions here on stackoverflow, tried most if not all of the suggestions, and so far, nothing has worked. I've looked through the various links and references suggested by the answers, including Apple's documentation, but none have pointed out the gap in my understanding. Any ideas would be appreciated.

    Read the article

  • How to create a paging scrollView with space between views

    - by user1558819
    I followed the tutorial about how to create a scrollView Page Control: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ This tutorial is really good and I implement well the code. Here my question: I want to put a space between the my PageViews, but when it change the page it show the space between the views in the next page. The scroll must stop after the space when I change the page. Someone can help me? I change the tutorial code here: - (void)viewDidLoad { [super viewDidLoad]; NSArray *colors = [NSArray arrayWithObjects:[UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil]; #define space 20 for (int i = 0; i < colors.count; i++) { CGRect frame; frame.origin.x = (self.scrollView.frame.size.width + space) * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; UIView *subview = [[UIView alloc] initWithFrame:frame]; subview.backgroundColor = [colors objectAtIndex:i]; [self.scrollView addSubview:subview]; [subview release]; } self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * colors.count+ space*(colors.count-1), self.scrollView.frame.size.height); } Thanks,

    Read the article

  • UIScrollView subviews not showing at first

    - by igul222
    I created a custom UIScrollView subclass that works a like a UITableView, keeping a collection of subviews and re-using them whenever the user scrolls. It's implemented like this: -(void)layoutSubviews { for(UIView *subview in [self subviews]) [subview removeFromSuperview]; // then re-add subviews after changing the frame and some attributes } This works fine with simple UIViews, but when I try to do it with a UIView that has a UILabel subview, the "base" view appears fine, but the UILabel doesn't show up at all. I can get the UILabel to show up by scrolling the entire UIView off screen and then bringing it back on. What could be causing this? So far, I've tried calling [myUIView setNeedsLayout], [myUIView setNeedsDisplay], and [myUIView layoutIfNeeded] from various places. None of them worked, and the last one crashed my app. I've also done the same thing to myUIScrollViewSubclass, with similar results.

    Read the article

  • Overload method (specifically drawRect:) without subclassing.

    - by SooDesuNe
    I'm using a container UIView to house a UIImageView and do some custom drawing. At this point I'd like to do some drawing on top of my subview. So overriding drawRect: in my container UIView will only draw below the subviews. Is there a way to overload drawRect: in my subview without subclassing it? I think method swizzling may be the answer, but I'm hoping not. (NOTE: yes, it would have been smarter to have the UIView be the subview of the UIImageView, but unfortunately I'm committed to my mistake now.)

    Read the article

  • Animating removeFromSuperview

    - by brettr
    I'd like to animate the transition from a subview back to the super view. I display the subview using: [UIView beginAnimations:@"curlup" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.5]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; [self.view addSubview:self.mysubview.view]; [UIView commitAnimations]; The above works fine. It's going back to the super view that I don't get any animation: [UIView beginAnimations:@"curldown" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.5]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; [self.view removeFromSuperview]; [UIView commitAnimations]; Is there something different I should be doing to get the subview to animate when removed?

    Read the article

  • zoomScale for OS 2.0

    - by sasayins
    Hi, Is there any alternative or work around so that I can use zoomScale in Iphone OS 2.0. It seems the property is only available in Iphone OS 3.0 or later? I have two subviews in my UIScrollView and if the first subview reach a specified scale then it will change to the other subview and save the current scale to zoomScale so that the new subview will apply to the previous scale. Like for example in, scrollViewDidEndZooming, scrollView.zoomScale = scale; When I run my app in Iphone OS 2.0, it gives me error saying invalid zoomScale invalid selector. How can I work around this? Thanks.

    Read the article

  • How can I make a core-plot graph on the phone that doesn't auto-expand to fill the whole superview

    - by Robb
    I'm pretty sure I saw an example where the graph wasn't filling the whole iPhone screen, but I can't get that to happen in my app, nor in the Core-Plot Test app from Switch On The Code. I've added a subview to the original CPLayerHostingView in the sample, then changed the classes – original back to UIView, new subview to CPLayerHostingView, and I've reconnected the File's owner's view outlet to the new subview. When I create a graph with: graph = [[CPXYGraph alloc] initWithFrame: theSubviewOutlet.bounds]; … and step through the first stages of building up the layers the bounds are accurate (i.e. the same as in the .xib) however, when all the initialization is done, and the graph shows up, it fills the whole superview. Am I missing something obvious?

    Read the article

  • addsubview animation works only first time

    - by Priya
    I am trying add subview with animation effect using the code which work fine for the first time below. CATransition *transition = [CATransition animation]; transition.duration = 1.0; transition.type = kCATransitionMoveIn; transition.subtype = kCATransitionFromRight; [newView.layer removeAllAnimations] [newView.layer addAnimation:transition forKey:nil]; [self.masterview addSubview:newView]; There is a back button in newView which removes the View from the superview. [newView removeFromSuperview]; Now when I try adding newView as subview again using the above code,its first adds the view as a subview(without animation) and again with animation.

    Read the article

  • UIImage in UIView and display image parts out of bounds

    - by Mpampinos Holmens
    I have an image in a subview that is bigger than the subview it self, is it possible to display parts of the image that are out of the subview! have tried the view.clipsToBounds=NO; but no lack still. here is part of my code so far. xRayView = [[XRayView alloc] initWithFrame: CGRectMake((1024 - 800) / 2, self.device.frame.origin.y - 26, 800,530)]; xRayView.clipsToBounds=NO; [xRayView setForgroundImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"xray_foreground_01" ofType: @"png"]]]; [xRayView setBackgroundImage: [UIImage imageWithContentsOfFile: [[NSBundle mainBundle] pathForResource: @"xray_background_01" ofType: @"png"]]]; the foreground and the background images are bigger than the xray view

    Read the article

  • Animating removeFromSuperview

    - by user230949
    I'd like to animate the transition from a subview back to the super view. I display the subview using: [UIView beginAnimations:@"curlup" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.5]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES]; [self.view addSubview:self.mysubview.view]; [UIView commitAnimations]; The above works fine. It's going back to the super view that I don't get any animation: [UIView beginAnimations:@"curldown" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDuration:.5]; [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES]; [self.view removeFromSuperview]; [UIView commitAnimations]; Is there something different I should be doing to get the subview to animate when removed?

    Read the article

  • UIActionSheet position on landscape and portrait

    - by Dave
    UIActionSheet positioning is not centered when I open it in landscape mode. If I set bounds or change the frame. The contents inside the UIActionSheet which is a subview changes but the actual sheet remains in the same place which looks very awkward. How do I move the UIActionSheet along with it's subview to the center of the screen?

    Read the article

  • add sub view in center - iPad

    - by Saurabh
    Hello All, I want to add a sub view in current view, this sub view is 300x300. When I add subview using [self.view addSubview:md.view]; the md.view will appear at position (0,0) is there any way to add subview in center? Thanks

    Read the article

  • Assigning ID to a Row in an Android ListView

    - by Chris
    I have a ListView. When an item on the ListView is tapped, it loads a SubView. I want to assign an ID to each row of the ListView, so I can pass that ID along to the SubView. How do I assign a specific ID to each row in the ListView? Here is how I am currently loading the ListView: setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, mArrayList));

    Read the article

  • UIScrollview disable transparency

    - by Frank
    It seems that UIScrollview has a transparency set by default. I have a background image set as a subview in self.view. but the image is showing on my scrollview that's also on the subview layer. I want it to cover up the background image so the scrollview transparency is disable.

    Read the article

  • Update iPhone UIProgressView during NSURLConnection download.

    - by Scott Pendleton
    I am using this code: NSURLConnection *oConnection=[[NSURLConnection alloc] initWithRequest:oRequest delegate:self]; to download a file, and I want to update a progress bar on a subview that I load. For that, I use this code: - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [oReceivedData appendData:data]; float n = oReceivedData.length; float d = self.iTotalSize; NSNumber *oNum = [NSNumber numberWithFloat:n/d]; self.oDPVC.oProgress.progress = [oNum floatValue]; } The subview is oDPVC, and the progress bar on it is oProgress. Setting the progress property does not update the control. From what I have read on the Web, lots of people want to do this and yet there is not a complete, reliable sample. Also, there is much contradictory advice. Some people think that you don't need a separate thread. Some say you need a background thread for the progress update. Some say no, do other things in the background and update the progress on the main thread. I've tried all the advice, and none of it works for me. One more thing, maybe this is a clue. I use this code to load the subview during applicationDidFinishLaunching: self.oDPVC = [[DownloadProgressViewController alloc] initWithNibName:@"DownloadProgressViewController" bundle:nil]; [window addSubview:self.oDPVC.view]; In the XIB file (which I have examined in both Interface Builder and in a text editor) the progress bar is 280 pixels wide. But when the view opens, it has somehow been adjusted to maybe half that width. Also, the background image of the view is default.png. Instead of appearing right on top of the default image, it is shoved up about 10 pixels, leaving a white bar across the bottom of the screen. Maybe that's a separate issue, maybe not.

    Read the article

  • Dragging an UIView inside UIScrollView

    - by Sergey Mikhanov
    Hello community! I am trying to solve a basic problem with drag and drop on iPhone. Here's my setup: I have a UIScrollView which has one large content subview (I'm able to scroll and zoom it) Content subview has several small tiles as subviews that should be dragged around inside it. My UIScrollView subclass has this method: - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { UIView *tile = [contentView pointInsideTiles:[self convertPoint:point toView:contentView] withEvent:event]; if (tile) { return tile; } else { return [super hitTest:point withEvent:event]; } } Content subview has this method: - (UIView *)pointInsideTiles:(CGPoint)point withEvent:(UIEvent *)event { for (TileView *tile in tiles) { if ([tile pointInside:[self convertPoint:point toView:tile] withEvent:event]) return tile; } return nil; } And tile view has this method: - (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { UITouch *touch = [touches anyObject]; CGPoint location = [touch locationInView:self.superview]; self.center = location; } This works, but not fully correct: the tile sometimes "falls down" during the drag process. More precisely, it stops receiving touchesMoved: invocations, and scroll view starts scrolling instead. I noticed that this depends on the drag speed: the faster I drag, the quicker the tile "falls". Any ideas on how to keep the tile glued to the dragging finger? Thanks in advance!

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >