Search Results

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

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

  • iPhone loading view from nib only works once

    - by The Swissdude
    Hi Forum I'm trying to add a «loader-view» to my app which shows a spinner while doing stuff. This works fine the first time, but it doesn't work a second time. here's what I do: I have a viewController for the spinner (spinnerViewController) and a nib-file which I made in IB (spinner.xib). I load the nib in the viewDidLoad-event: spinnerView = [[spinnerViewController alloc] initWithNibName:@"spinner" bundle:nil]; [spinnerView retain]; spinnerView is declared in the .h-file (spinnerViewController *spinnerView;) next, I show the spinner-view: [self.view addSubview:spinnerView.view]; [self.view bringSubviewToFront:spinnerView.view]; which works fine... And now the trouble starts. No matter what I do, I can't show the spinner view again. I tried just hiding it (self.view sendSubViewToBack: spinnerView.view) which works for hiding, but when I try to bring it to the front again (self.view bringSubViewToFront: spinnerView.view) it doesn't work. I also tried removing the spinner-view and add it again with no success (within the spinnerViewController: [self.view removeFromSuperview] and to show it again [self.view addSubview... ) Any ideas what I'm doing wrong??? ;) Thanks for the help!

    Read the article

  • Adding a custom subview (created in a xib) to a view controller's view - What am I doing wrong

    - by Fran
    I've created a view in a xib (with an activity indicator, a progress view and a label). Then I've created .h/.m files: #import <UIKit/UIKit.h> @interface MyCustomView : UIView { IBOutlet UIActivityIndicatorView *actIndicator; IBOutlet UIProgressView *progressBar; IBOutlet UILabel *statusMsg; } @end #import "MyCustomView.h" @implementation MyCustomView - (id)initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { // Initialization code } return self; } - (void)dealloc { [super dealloc]; } @end In IB, I set the file's owner and view identity to MyCustomView and connect the IBOutlet to the File's owner In MyViewController.m, I've: - (void)viewDidLoad { [super viewDidLoad]; UIView *subView = [[MyCustomView alloc] initWithFrame:myTableView.frame]; [subView setBackgroundColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5]]; [myTableView addSubview:subView]; [subView release]; } When I run the app, the view is added, but I can't see the label, the progress bar and the activity indicator. What am I doing wrong?

    Read the article

  • How can I remove the present view when I have added more than one subView ?

    - by srikanth rongali
    How can I remove the present view when I touched the close button. I did [self.view removeFromSuperView] when I added only one subView. It worked. But, I have now added another subView to the previous subView. I need to to get the parent view . How can I do it. My code of adding the subView is here. When I did the following only one view is removed. //FirstViewController: UIViewController -(void)libraryFunction:(id)sender { LibraryController *libraryController = [[LibraryController alloc]init]; [self.view addSubview:libraryController.view]; } //LibraryController: UIViewController -(void)viewDidLoad{ RootViewController *rootViewController = [[RootViewController alloc] initWithStyle:UITableViewStylePlain]; UINavigationController *aNavigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController]; self.navController = aNavigationController; [aNavigationController release]; [rootViewController release]; [self.view addSubview:navController.view]; } //RootViewController: UITableViewController - (void)viewDidLoad { [super viewDidLoad]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)]; } -(void)close:(id)sender { [self.view removeFromSuperview]; } Thank You.

    Read the article

  • Assigning a view controller to be the delegate of a subview which is not directly descendent?

    - by ambertch
    I am writing an iphone app where in numerous cases a subview needs to talk to its superview. For example: View A has a table view that contains photos A has a subview B which allows users to add photos, upon which I want to auto append them to A's table view So far I have been creating a @protocol in B, and registering A as the delegate. The problem in my case is that B has a subview C that allows users to add content, and I want actions in C to invoke changes in its grandparent, A. Currently I am working around this by passing around a self pointer to my base view controller (C.delegate = B.delegate), but it doesn't seem very proper to me. Any thoughts? (and/or general advice on code organization when all sort of subviews needs to talk to superviews would be greatly appreciated) Thanks!

    Read the article

  • How can the subView detect that the mainView is rotating?

    - by wolverine
    I have a mainView. To this view, I am adding a view of the same size. When the mainView(the background) rotates, its being detected but the subview doesnt have any idea about being rotated. And its functions are not even being called. Even when the program launches too, if I am in landscape mode, its the same way. How can I make the subView know that the device is being rotated?

    Read the article

  • Converting a CGRect of a object in a subview in UITableViewCell in UITable to CGRect with respect to

    - by user362956
    Hey, I want to converte a CGRect "aRect" of a object in a subview in UITableViewCell in UITable to CGRect with respect to self.view. The problem is that aRect is with respect to the subview in the table cell. But i want to make it so that it is with respect to self.view What i tried is this rect = [self.view convertRect:aRect.frame toView:cellView]; but it doesn't work. So how to convert it?

    Read the article

  • How can display gif on a subview in iPhone using glgif?

    - by iPhoney
    I want to display a gif image on a subview in iPhone. The sample code glgif shows the gif image on the controller's root view, but when I make the following modifications, the application just crashes: IBOutlet UIView *gifView; // gifView is added as a subview of controller's root view //PlayerView *plView = (PlayerView *)self.view; PlayerView *plView = (PlayerView *)gifView; // Load test.gif VideoSource NSString *str = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"gif"]; FILE *fp = fopen([str UTF8String], "r"); VideoSource *src = VideoSource_init(fp, VIDEOSOURCE_FILE); src->writeable = false; // Init video using VideoSource Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]]; VideoSource_release(src); // Start if loaded if (vid) { [plView startAnimation:vid]; [vid release]; return; } // Cleanup if failed fclose(fp); Now the app crashes in this line: Video *vid = [[GifVideo alloc] initWithSource:src inContext:[plView context]]; with the error message:-[UIView context]: unrecognized selector sent to instance. Any ideas about how to add the plView to the subview properly?

    Read the article

  • What is the correct way to add a subview to a new window, making it aware of its available window si

    - by favo
    Hi, This is some kind of a basic question: I am adding a new Subview to a window using: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { viewController = [[myViewController alloc] initWithNibName:@"myNib" bundle:nil]; [window addSubview:viewController.view]; This displays the view at 100% on the window, having the Clock overlaying some pixels of that view on top. Rotating makes the view aware of the clock and resizes it to begin correctly below the clock without any overlay. What is the correct way to add a subview to a new window, making it aware of its available window size?

    Read the article

  • Adding a subview larger than cellHeight to a UITableViewCell?

    - by MathieuK
    I'm trying to add a subview to a UITableViewCell and the design that I'm working from demands that this particular subview (an image) needs to be larger than the actual UITableViewCell and thus partly overlap its siblings. So I've set up my table cell, generated my image and added it to the cell's contentView: // rowHeight for the UITableView is 45.0f UIImage *image = [self createCellThumbnail: someImage]; UIImageView *thumbView = [[UIImageView alloc] initWithFrame: CGRectMake(150, -5, 55,55)]; thumbView.transform = CGAffineTransformMakeRotation(0.1f); thumbView.image = image; cell.clipsToBounds = NO; cell.contentView.clipsToBounds = NO; [cell.contentView addSubview: thumbView]; While the image will 'overflow' into the cell below it, the top of the image is always clipped, as demonstrated here: http://imgur.com/WDsAx . Does anyone know if what I'm trying to do is possible with the current approach or should I just figure out a way to draw these images onto the UITableView after all the cells are drawn (it's a non-scrollable tableview, so that would work and be fairly easy).

    Read the article

  • Isn't it better to create the subview hierarchy in -viewDidLoad rather than in -loadView?

    - by dontWatchMyProfile
    The docs say that the whole subview hierarchy can be created in -loadView. But there's also this -viewDidLoad method which sounds nice to ovewrite for actually building the hierarchy, when the view loaded. I guess it's a matter of taste only. But maybe doing so in -viewDidLoad hast the advantage that the view controller already adjusted the frame of the view correctly to accomodate for the status bar or any other kind of bar like tab bar or tool bar?

    Read the article

  • How can I click a button behind a transparent UIView?

    - by Sean Clark Hess
    Let's say we have a view controller with one sub view. the subview takes up the center of the screen with 100 px margins on all sides. We then add a bunch of little stuff to click on inside that subview. We are only using the subview to take advantage of the new frame ( x=0, y=0 inside the subview is actually 100,100 in the parent view). Then, imagine that we have something behind the subview, like a menu. I want the user to be able to select any of the "little stuff" in the subview, but if there is nothing there, I want touches to pass through it (since the background is clear anyway) to the buttons behind it. How can I do this? It looks like touchesBegan goes through, but buttons don't work.

    Read the article

  • iphone - UITapGestureRecognizer problem

    - by Mike
    I have two UIImageViews one as subview of the other. The subview is smaller and is centered on the screen. Both have UITapGestureRecognizer assigned and both were intended to respond to single taps. A single tap on the main view (= the area outside the subview) is fine, but a tap inside the subview is seen as the main view as a tap too. How can I have this to work independently? both views have setCancelsTouchesInView and setDelaysTouchesEnded set to NO and both have the same delegate (yes, I need to have the same delegate and cannot change that). How may I force the main view to ignore any tap on the area that belongs to its subview? thanks for any help.

    Read the article

  • QTMovieView always remains at top

    - by Pickasaby
    I have made an applications which contains a main canvas view. In which i add some subview (NSView) of different kind. Means say subView1 is a container for PDFView, subView 2 is a container for a WebView and subView 3 is a container for QTMovieView. I can select and drag these views on main canvas view. The strange thing that happens is, when ever i drag a subview 1 or 2 and it intersects subview 3, sunbview 3 never allows any other view to come on top of it, coz it contains a 'QTMovieView' . I tried replacing QTMovieView with QTMovieLayer, and then attach a QTMovie with QTMovieLayer, still the problem prevails. Is there any way so that my QTMovieView/QTMovieLayer acts in a normal manner as does other NSView do.

    Read the article

  • presentModalViewController does not want to work when called from a protocol method

    - by johnbdh
    I have a subview that when double tapped a protocol method on the subview's parent view controller is called like this... - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *theTouch = [touches anyObject]; if (theTouch.tapCount == 1) { } else if (theTouch.tapCount == 2) { if ([self.delegate respondsToSelector:@selector(editEvent:)]) { [self.delegate editEvent:dictionary]; } } } Here is the protocol method with the dictionary consuming code removed... - (void)editEvent:(NSDictionary){ EventEditViewController *eventEditViewController = [[EventEditViewController alloc] initWithNibName:@"EventEditViewController" bundle:nil]; eventEditViewController.delegate = self; navigationController = [[UINavigationController alloc] initWithRootViewController:eventEditViewController]; [self presentModalViewController:navigationController animated:YES]; [eventEditViewController release]; } The protocol method is called and runs without any errors but the modal view does not present itself. I temporarily copied the protocol method's code to an IBAction method for one of the parent's view button's to isolate it from the subview. When I tap this button the modal view works fine. Can anyone tell me what I am doing wrong? Why does it work when executed from a button on the parent view, and not from a protocol method called from a subview. Here is what I have tried so far to work around the problem... Restarted xCode and the simulator Ran on the device (iTouch) Presenting eventEditViewController instead of navigationController Using Push instead of presentModal. delaying the call to the protocol with performSelector directly to the protocol, to another method in the subview which calls the protocol method, from the protocol method to another method with the presentModal calls. Using a timer. I have it currently setup so that the protocol method calls a known working method that presents a different view. Before calling presentModalViewController it pops a UIAlertView which works every time, but the modal view refuses to display when called via the protocol method. I'm stumped. Perhaps it has something to do with the fact that I am calling the protocol method from a UIView class instead of a UIViewController class. Maybe I need to create a UIViewController for the subView?? Thanks, John

    Read the article

  • query regarding fixing the page size

    - by sukhada
    -- <f:subview id="header"> <tiles:insert definition="page.header" flush="false"/> </f:subview> <!-- </h:panelGroup>--> <h:panelGroup id="topMenu" > <tiles:insert definition="page.topMenu" flush="false"/> </h:panelGroup> <h:panelGroup id="pageContext"> <f:subview id="body"> <tiles:insert attribute="body" flush="false"/> </f:subview> </h:panelGroup> <f:facet name="footer"> <f:subview id="footer"> <tiles:insert definition="page.footer" flush="false"/> </f:subview> </f:facet> </h:panelGrid> this is structure or layout of page in tiles but m loading another page the it disturbing the layout the layout so how can i fix the page size?

    Read the article

  • How to make the subview in a UIScrollView to refresh when we zoom it?

    - by wolverine
    I have subclassed UIView object inside a uiscrollview which displays a pdf page. I can zoom that page. But when I do so, the inside view is zoomed and is getting blurred. I understood that the inner view shud be refreshed and i called setNeedsDisplay. But no change have happened and its the same even now. Below is the code for drawRect for the subclassed uiview. - (void)drawRect:(CGRect)rect { if(document)//the pdf document object { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGContextTranslateCTM(ctx, 0.00, [self bounds].size.height); NSLog(@"%f",[self bounds].size.height); CGContextScaleCTM(ctx, 1.0, -1.0); CGContextConcatCTM(ctx, CGPDFPageGetDrawingTransform(page, kCGPDFCropBox, [self bounds], 0, true)); CGContextDrawPDFPage(ctx, page); CGContextRestoreGState(ctx); } }

    Read the article

  • how to create iPhone main menu screen with 2 tabbars subview ?

    - by Boaz
    Hi. I made two applications that each one of them is tabbar based. Now I want to combine them to one app that will be struct like that: -Main menu with 2 buttones. - button 1: tab bar app no 1. - button 2: tab bar app no 2. from each tab bar app, I want an Home button on the left side of the nav bar that will take me to the main menu. I found this link http://www.pushplay.net/blog_detail.php?id=27 but it's not good to me.. I will be happy if you will able to post some simple code for my problem.. Thanks.

    Read the article

  • Can I detect if higher subview has been touched?

    - by Kevin Beimers
    I've got a big UIView that responds to touches, and it's covered with lots of little UIViews that respond differently to touches. Is it possible to touch anywhere on screen and slide around, and have each view know if it's being touched? For example, I put my finger down on the upper left and slide toward the lower right. The touchesBegan/Moved is collected by the baseView. As I pass over itemView1, itemView2, and itemView3, control passes to them. If I lift my finger while over itemView2, it performs itemView2's touchesEnded method. If I lift my finger over none of the items, it performs baseView's touchesEnded. At the moment, if I touch down on baseView, touchEnded is always baseView and the higher itemViews are ignored. Any ideas?

    Read the article

  • Adding a view with a view controller as a subview of another view controller. Doesn't work.

    - by Tom
    I'm trying to essentially re-implement the UISplitViewController (because it has its limits), but when I create a UIViewController viewController, and then do an "[viewController.view addSubview contentViewController.view]" on it, to add a view that already has a view controller, that content view doesn't seem to get initialised by its view controller. I guess its view controller is getting detached or deallocated, is this the case?

    Read the article

  • Model-View-Controller in JavaScript

    - by Casey Hope
    tl;dr: How does one implement MVC in JavaScript in a clean way? I'm trying to implement MVC in JavaScript. I have googled and reorganized with my code countless times but have not found a suitable solution. (The code just doesn't "feel right".) Here's how I'm going about it right now. It's incredibly complicated and is a pain to work with (but still better than the pile of code I had before). It has ugly workarounds that sort of defeat the purpose of MVC. And behold, the mess, if you're really brave: // Create a "main model" var main = Model0(); function Model0() { // Create an associated view and store its methods in "view" var view = View0(); // Create a submodel and pass it a function // that will "subviewify" the submodel's view var model1 = Model1(function (subview) { view.subviewify(subview); }); // Return model methods that can be used by // the controller (the onchange handlers) return { 'updateModel1': function (newValue) { model1.update(newValue); } }; } function Model1(makeSubView) { var info = ''; // Make an associated view and attach the view // to the parent view using the passed function var view = View1(); makeSubView(view.__view); // Dirty dirty // Return model methods that can be used by // the parent model (and so the controller) return { 'update': function (newValue) { info = newValue; // Notify the view of the new information view.events.value(info); } }; } function View0() { var thing = document.getElementById('theDiv'); var input = document.getElementById('theInput'); // This is the "controller", bear with me input.onchange = function () { // Ugly, uses a global to contact the model main.updateModel1(this.value); }; return { 'events': {}, // Adds a subview to this view. 'subviewify': function (subview) { thing.appendChild(subview); } }; } // This is a subview. function View1() { var element = document.createElement('div'); return { 'events': { // When the value changes this is // called so the view can be updated 'value': function (newValue) { element.innerHTML = newValue; } }, // ..Expose the DOM representation of the subview // so it can be attached to a parent view '__view': element }; } How does one implement MVC in JavaScript in a cleaner way? How can I improve this system? Or is this the completely wrong way to go, should I follow another pattern?

    Read the article

  • Optimized Image Loading in a UIScrollView

    - by Michael Gaylord
    I have a UIScrollView that has a set of images loaded side-by-side inside it. You can see an example of my app here: http://www.42restaurants.com. My problem comes in with memory usage. I want to lazy load the images as they are about to appear on the screen and unload images that aren't on screen. As you can see in the code I work out at a minimum which image I need to load and then assign the loading portion to an NSOperation and place it on an NSOperationQueue. Everything works great apart from a jerky scrolling experience. I don't know if anyone has any ideas as to how I can make this even more optimized, so that the loading time of each image is minimized or so that the scrolling is less jerky. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{ [self manageThumbs]; } - (void) manageThumbs{ int centerIndex = [self centerThumbIndex]; if(lastCenterIndex == centerIndex){ return; } if(centerIndex >= totalThumbs){ return; } NSRange unloadRange; NSRange loadRange; int totalChange = lastCenterIndex - centerIndex; if(totalChange > 0){ //scrolling backwards loadRange.length = fabsf(totalChange); loadRange.location = centerIndex - 5; unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex + 6; }else if(totalChange < 0){ //scrolling forwards unloadRange.length = fabsf(totalChange); unloadRange.location = centerIndex - 6; loadRange.length = fabsf(totalChange); loadRange.location = centerIndex + 5; } [self unloadImages:unloadRange]; [self loadImages:loadRange]; lastCenterIndex = centerIndex; return; } - (void) unloadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(thumbView.loaded){ UnloadImageOperation *unloadOperation = [[UnloadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:unloadOperation]; [unloadOperation release]; } } } } - (void) loadImages:(NSRange)range{ UIScrollView *scrollView = (UIScrollView *)[[self.view subviews] objectAtIndex:0]; for(int i = 0; i < range.length && range.location + i < [scrollView.subviews count]; i++){ UIView *subview = [scrollView.subviews objectAtIndex:(range.location + i)]; if(subview != nil && [subview isKindOfClass:[ThumbnailView class]]){ ThumbnailView *thumbView = (ThumbnailView *)subview; if(!thumbView.loaded){ LoadImageOperation *loadOperation = [[LoadImageOperation alloc] initWithOperableImage:thumbView]; [queue addOperation:loadOperation]; [loadOperation release]; } } } } EDIT: Thanks for the really great responses. Here is my NSOperation code and ThumbnailView code. I tried a couple of things over the weekend but I only managed to improve performance by suspending the operation queue during scrolling and resuming it when scrolling is finished. Here are my code snippets: //In the init method queue = [[NSOperationQueue alloc] init]; [queue setMaxConcurrentOperationCount:4]; //In the thumbnail view the loadImage and unloadImage methods - (void) loadImage{ if(!loaded){ NSString *filename = [NSString stringWithFormat:@"%03d-cover-front", recipe.identifier, recipe.identifier]; NSString *directory = [NSString stringWithFormat:@"RestaurantContent/%03d", recipe.identifier]; NSString *path = [[NSBundle mainBundle] pathForResource:filename ofType:@"png" inDirectory:directory]; UIImage *image = [UIImage imageWithContentsOfFile:path]; imageView = [[ImageView alloc] initWithImage:image andFrame:CGRectMake(0.0f, 0.0f, 176.0f, 262.0f)]; [self addSubview:imageView]; [self sendSubviewToBack:imageView]; [imageView release]; loaded = YES; } } - (void) unloadImage{ if(loaded){ [imageView removeFromSuperview]; imageView = nil; loaded = NO; } } Then my load and unload operations: - (id) initWithOperableImage:(id<OperableImage>) anOperableImage{ self = [super init]; if (self != nil) { self.image = anOperableImage; } return self; } //This is the main method in the load image operation - (void)main { [image loadImage]; } //This is the main method in the unload image operation - (void)main { [image unloadImage]; }

    Read the article

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