Setting up a UIWebView delegate

Ok, this should be simple, but for some reason I'm lost.
Primarily, because the different objects are in different modules
and there doesn't seem to be a clean way to tie them together.
I start with a UIView in a simple ViewController.
Next, I want to switch views, by calling a 2nd ViewController. The 2nd controller loads from a nib file, a view with a navbar and a webview. I currently call this from:
// ViewController.h
- (IBAction)showWebView {
AViewController *controller = [[AViewController alloc]
initWithNibName:@"AViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
// AViewController.h
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
UIWebView* webView = [self myWebView]; // get webview from array of subviews
NSString* path = [[NSBundle mainBundle] pathForResource:@"MyWebPage" ofType:@"html"];
NSURL* fileURL = [[NSURL alloc] initFileURLWithPath:path];
NSURLRequest* req = [NSURLRequest requestWithURL:fileURL];
[webView loadRequest:req];
} // if self = super
return self;
} which sets up a modal view using an animated transition.
The problem is that the UIWebView always starts out with a white screen, which shows white until the webpage is loaded.
Ok, the solution is to use a UIWebViewDelegate. All the examples I see using the delegate say to add the delegate to the webview at load time and then when delegate methodwebViewDidFinishLoadis called, then make the view appear. Ok, I want the modal view to be called AFTER the view is loaded.
So, how do I split up my code to do this? Where do and how do I set the delegate, and where do I put the webViewDidFinishLoad method? (in ViewController, or in AViewController)
If I set the delegate in AViewController in initWithNibName, I would guess the delegate would be something like webView.delegate = self.parentViewController;
but, then I have the issue of how to split up the showWebView method, to create and release the controller properly, and to call presentModalViewController.
What is the proper way to do this? Is there any sample code that does this the approved way?

I believe I understand what you're saying, and I think I may have implemented it the second way, but... my delegate method, webViewDidFinishLoad never gets called. So, some sample code would help.
Here's what I did:
// FlipsideViewController.h
#import "InstructionsViewController.h"
@interface FlipsideViewController : UIViewController <UIWebViewDelegate> {
id <FlipsideViewControllerDelegate> delegate;
InstructionsViewController* instructionsViewController;
@property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate;
@property (nonatomic, retain) InstructionsViewController* instructionsViewController;
- (IBAction)showInstructions;
@end
// FlipsideViewController.m
@synthesize delegate;
@synthesize instructionsViewController;;
- (IBAction)showInstructions {
instructionsViewController = [[InstructionsViewController alloc]
initWithNibName:@"InstructionsView" bundle:nil];
/* -- commented out, view never shows, if in, issue is the same, view flashes white before load
instructionsViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:instructionsViewController animated:YES];
[instructionsViewController release];
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"webView error: %@",[error description]);
// do something here for web page load error
- (void)webViewDidFinishLoad:(UIWebView*)webView {
NSLog(@"Delegate FSV webViewDidFinishLoad");
instructionsViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:instructionsViewController animated:YES];
[instructionsViewController release];
// InstructionsViewController.m
#import "InstructionsViewController.h"
#import "FlipsideViewController.h"
@implementation InstructionsViewController
- (UIWebView*)myWebView { // routine in case needed more than once.
NSArray* views = [[NSArray alloc] initWithArray:[self.view subviews]];
NSEnumerator *enumerator = [views objectEnumerator];
id anObject;
while (anObject = [enumerator nextObject]) {
if ( [anObject isKindOfClass:[UIWebView class]] ) {
[views autorelease];
return anObject;
} // if anObject
} // while
[views release];
return nil;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
UIWebView* webView;
webView = [self myWebView];
webView.delegate = (FlipsideViewController*)self.parentViewController;
NSString* path = [[NSBundle mainBundle] pathForResource:@"myHTMLfile" ofType:@"html"];
NSURL* fileURL = [[NSURL alloc] initFileURLWithPath:path];
NSURLRequest* req = [NSURLRequest requestWithURL:fileURL];
[webView loadRequest:req];
} // if self = super
return self;
- (void)webViewDidFinishLoad:(UIWebView*)webView {
NSLog(@"Delegate IVC webViewDidFinishLoad");
InstructionsViewController* controller = (InstructionsViewController*) webView.delegate;
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
You may notice that webViewDidFinishLoad appears in BOTH .m files. I put it initially in FlipsideViewController, thinking that is where it belonged, as it was what I thought I set as the delegate. However the routine was never hit, so I tried a copy in the other module. NEITHER gets hit.
Thanks for your help on this one.

Similar Messages

  • Setting up BitLocker missing delegate control setting

    Hi,
    I am setting up BitLocker in our AD. I checked the schema using ADSI edit and it looks as if the schema is already extended.
    I find:
    CN=ms-FVE-KeyPackage
    CN=ms-FVE-RecoveryGuid
    CN=ms-FVE-RecoveryInformation
    CN=ms-FVE-RecoveryPassword
    CN=ms-FVE-VolumeGuid
    CN=ms-TPM-OwnerInformation
    So, now i want to delagate permissions in AD on the workastations OU for the SELF account.
    In the delegate wizard i can only find Write msTPM-OwnerInformation.
    On the technet page jj592683 ("Prepare your organization for BitLocker:..." "Applies To: Windows 8, Windows 8.1"), it referes to both Write msTPM-OwnerInformation and Write msTPM-TpmInformationForComputer.
    However in the delegate wizard i cannot find Write msTPM-TpmInformationForComputer.
    What is missing?
    This posting is provided "AS IS" with no warranties or guarantees and confers no rights

    Hi,
    I am setting up BitLocker in our AD. I checked the schema using ADSI edit and it looks as if the schema is already extended.
    I find:
    CN=ms-FVE-KeyPackage
    CN=ms-FVE-RecoveryGuid
    CN=ms-FVE-RecoveryInformation
    CN=ms-FVE-RecoveryPassword
    CN=ms-FVE-VolumeGuid
    CN=ms-TPM-OwnerInformation
    So, now i want to delagate permissions in AD on the workastations OU for the SELF account.
    In the delegate wizard i can only find Write msTPM-OwnerInformation.
    On the technet page jj592683 ("Prepare your organization for BitLocker:..." "Applies To: Windows 8, Windows 8.1"), it referes to both Write msTPM-OwnerInformation and Write msTPM-TpmInformationForComputer.
    However in the delegate wizard i cannot find Write msTPM-TpmInformationForComputer.
    What is missing?
    This posting is provided "AS IS" with no warranties or guarantees and confers no rights
    "msTPM-TpmInformationForComputer" comes with Windows Server 2012 schema extensions and later: http://msdn.microsoft.com/en-us/library/hh554139.aspx
    The other attributes listed all came with Windows Vista/Windows Server 2008. Have you extended your schema for Windows Server 2012 or Windows Server 2012 R2?
    dsquery * cn=schema,cn=configuration,dc=domainname,dc=com -scope base -attr objectVersion
    You need at least schema version 56.
    Enfo Zipper
    Christoffer Andersson – Principal Advisor
    http://blogs.chrisse.se - Directory Services Blog

  • How to Set User-Agent in UIWebView?

    I tried to change User-Agent using NSMutableURLRequest in the UIWebView delegate function, but didn't work. The funny thing is...the User-Agent string changed if the request is redirect. Have anyone experienced it? I want to change User-Agent of every request from UIWebView to the same like coming from Safari browser. Please HELP!!

    I would try the Apple Developer Connection, this forum is for users of the iPhone, you aren't going to get much help with this.

  • UITableView - How do you set datasource and delegate? Please help

    I've been looking through documentation, code examples, and searching online but I can't seem to find out how to use a UITableView that I've have placed inside of my view using Interface Builder.
    In my UIViewController class for the view I have a UITableView *tblView linked to my table view in Interface Builder. All I want to do now is be able to implement numberOfRowsInSection, and cellForRowAtIndexPath so that I can populate my table view.
    I've read that I have to set the datasource and delegate to be able to populate the table view and process events. How do I do this properly so that I can implement the methods for the UITableView in my view controller class?
    Any help would be greatly appreciated. Thanks!

    Hi, if you'Re using interface builder than you just have to control-drag (click on hold the left mousebutton while pressing the control-key) from the tableView to the viewController. You need to do this two times (delegate and dataSource each in one step).

  • Images in UIWebView

    While in Safari, tapping on an image pops up a menu showing options like 'set as wallpaper' etc ... but when viewing same webpage in UIWebView, tapping on image shows nothing.
    Can anybody tell what is it?

    I just ran a test and found a way to do this. The UIWebView delegate method 'shouldStartLoadWithRequest' has as one of its arguments an NSURLRequest object. Happily this is really a NSMutableURLRequest (at least in my quick test). A mutable request allows you to set any HTTP header including user agent. No guarantee that a given site will work properly inside UIWebView but at least you can try different user agent strings and see what happens.
    You can't use mobile Safari IN your app but you can launch it FROM your app. Of course your app terminates at that point.

  • IPad UIWebView and different versions of XCode

    I have an iPad app with a UIWebView which loads some local .rtfd.zip files. The problem is that if I compile the app with XCode 3.2.2, everything works fine, but if I compile it with newer versions of XCode, I just get a blank UIWebView. Here's how I load the files into the UIWebVIew:
    - (void)loadFile:(NSString*)file
    NSString* resourcePath = [[NSBundle mainBundle] bundlePath];
    NSString* sourceFilePath = [resourcePath stringByAppendingPathComponent:file];
    NSURL* url = [NSURL fileURLWithPath:sourceFilePath isDirectory:NO];
    NSURLRequest* request = [NSURLRequest requestWithURL:url];
    [webview loadRequest:request];
    [resourcePath release];
    All the testing is done in the simulator.
    Can you help me?
    Thanks in advance!

    I have the same problem and still investigating the cause. From a bit a searching, it seems that it may be caused by the way I set up my UIWebView to receive taps (I subclassed a UIView that wraps a UIWebView).
    Here is a promising post about the solution:
    http://mithin.in/2009/08/26/detecting-taps-and-events-on-uiwebview-the-right-way /

  • UI-delegate architecture for complex components

    Hello,
    I've got a question regarding how to architect a new complex component (similar to a color-chooser for example) to be very reusable and configurable with respect to the Swing architecture:
    When implementing such a reusable and configurable component (like a color-chooser for example) should I implement an UI-delegate fitting into Swing's MVC way, or should I implement the view on my own architecture following more general MVC.
    The component I am about to develop is a composition of other controls (like a color-chooser is compound of a tabbed-pane, a few buttons, a few panels, and a few sliders). So does implementing a UI-delegate with such a coarse-graind component make sense? I seem (or at least hope) to have understood what a UI-delegate is intended for when dealing with atomic controls (like buttons, labels, comboboxes, etc.), but does a UI-delegate make sense when dealing with larger aggregated components?
    For instance, when setting a custom UI-delegate implementation for a JColorChooser (overwritten from javax.swing.plaf.basic.BasicColorChooserUI), the "paint"-method gets called but seems to be useless, since overwriting it does not produce any effect on how the color-chooser is presented (as I expected, since the JColorChooser is made out of other controls and therefore does not implement its own painting directly). So am I missing some important point here, or is the UI-delegate thing not really intended for compound components made of other smaller ones, and therefore - for the compound components - just a retrofitted implementation to make all Swing components alike?
    So my question is about architecture of a larger component than for what I believe a UI-delegate was intended for. But though I would like to be as close to Swing's way of doing it as possible... So if it would be cleaner to fit my component into the UI-delegate way of doing it, how - for example - do I register a default UI-delegate implementation with the current L&F? And what happens if a user switches to another L&F that does not implement (neither directly nor through inheritance) my component's UI-delegate?
    Please correct me if I am missing some point here or heading into the completely wrong direction!
    Steve

    Hi,
    it seems you are talking about javabean.

  • How to show the pdf file into the UIWebView from iphone documents directory?

    Hi ,
         I am working on web services right now I am getting string into base64 format. After decoding that string into NSData i am saving that data as a pdf into Document directory of iphone. Now the problem is that when I want to show the pdf into UIwebView then it is showing blank page. But when I am checking into /Users/pareshkarnawat/Library/Application Support/iPhone Simulator/4.3.2/Applications/ the pdf file is correctly generated and working fine when I ope it.
       How to show that pdf file into UIwebview ? or is there any alernative for this.
    Any ideas on how I can go about this? I have looked at a few posts and still can't seem to figure it out.
    Any idea's appreciated, thanks

    The result is a UIWebView that displays a blank page. No errors occur in the UIWebView delegate method. The thing is that data has the correct length, in bytes, for the PDF I am trying to display, and I also get the pdf file in Library/Application Support/iPhone Simulator/4.3.2/Applications/ Does anyone have an idea as to what might be going wrong here or how I can better debug this problem?

  • Regarding the delegate for NSTabView

    Hi all ,
    I am developing a small application where I have have NSTabView .My each TabItem has a view in it i.e. DropBox derived from NSView.I want to drag and drop and perfom some task on the corresponding selected TabItem.
    I have created an id delegate and set this as a delegate for an instance of MyController i.e(Control-Drag from instance of DropBox to instance of MyController).The problem I am facing is that the respondsToSelector method always returns NO.As a result if I select any TabItem it always returns zero(i.e the first tab item).Also it does not show any error while compiling.Following is my code:-
    //DropBox.m
    @interface NSObject ( MyObjectDelegateMethod)
    -(int)getTerminal;
    @end
    @implementation DropBox
    - (BOOL)performDragOperation: ( id <NSDraggingInfo>)sender
    if (![delegate respondsToSelector:@selector(getTerminal)]){
    NSLog( @"performDragOperation : Returning NO");
    return NO;
    switch([delegate getTerminal] )
    case 1 : //task1
    case2 : //task2
    - (id) delegate;
    NSLog( @"Returning the delegate for MyController.");
    return delegate;
    - (void)setDelegate: ( id)theDelegate;
    NSLog( @"The delegate for MyController is set");
    delegate = theDelegate;
    NSLog(@"delegate:%@", delegate);
    @end
    //DropBox.h
    #include"MyController.h"
    @interface DropBox : NSView
    id delegate;
    - (id)delegate;
    - (void)setDelegate: ( id)theDelegate;
    @end
    //MyController.m
    -(int) getTerminal
    return [myTab indexOfTabViewItem:[myTab selectedTabViewItem]];
    //MyController.h
    #import <Cocoa/Cocoa.h>
    @interface MyController : NSObject
    IBOutlet id myTab;
    -(int) getTerminal;
    @end
      Mac OS X (10.4.9)  

    Hi
    The stock monitoring for SC stocks at vendor can be done uswing ME2O report.
    If you want to see the total stocks available at vendor then use report MBLB

  • Beginning cocoa programming: delegates

    Xcode 3.2.2
    Mac OS X 10.6.8
    Cocoa Programming for Mac OS X (third edition)
    Chapter 6: Helper objects
    What happened to the forum software?  I can't quote text/code anymore.
    I'm trying to create a simple delegate for an NSWindow.  The delegate implements this method:
    - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize;
    I can get my delegate to work if I use Interface Builder to connect my app's main(and only) window to an instance of my object(which appears in the MainMenu.xib inspector in IB).  However, I cannot get a delegate to work if I call setDelegate: on my app's main window.  In the book, there is one example where they use setDelegate: to setup the delegate object.  There is another example where they use IB to hook up the delegate.  The only distinction I can detect between the two examples is that in the one that employs setDelegate:, the delegate-or is not a widget, and in the one that uses IB to make the connection, the delegate-or is a widget.
    This is the code that I used to try and programmatically set up a delegate:
    //AppController.h
    #import <Cocoa/Cocoa.h>
    @interface AppController : NSObject {
      IBOutlet NSWindow* window;
    - (id)init;
    @end
    //AppController.m
    #import "AppController.h"
    #import "MyDelegate.h"
    @implementation AppController
    - (id)init
      if (![super init]) {
      return nil;
      MyDelegate* aDelegate = [[MyDelegate alloc] init];
      [window setDelegate:aDelegate];
      return self;
    @end
    //MyDelegate.h
    #import <Cocoa/Cocoa.h>
    @interface MyDelegate : NSObject <NSWindowDelegate> {
    - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize;
    @end
    //MyDelegate.m
    #import "MyDelegate.h"
    @implementation MyDelegate
    - (NSSize)windowWillResize:(NSWindow *)sender
                             toSize:(NSSize)frameSize
         frameSize.height = 2 * frameSize.width;
         return frameSize;
    @end
    In IB, I went into the Library, and I dragged an Object to the MainMenu.xib window/inspector, and I named it AppController.  Then I dragged a connection from the AppController outlet named 'window' to the NSWindow.  When I build&run my code, I can resize the window to any size--the window size is not constrained to a 2:1 ratio. That is not the result I expect: I expect the window size to maintain a 2:1 ration. If I set an object's delegate, then when the event occurs, the object should grab the delegate and use it to call the delegation methods; there is nothing more I should have to do in my code.  What am I not understanding about cocoa delegates?

    I constructed another simple example of a delegate: I created an app with one lone NSTextField on the window.  I wanted to see if setDelegate: would work with a different widget(NSTextField v. NSWindow).  My goal was to see if I could setup a delegate using setDelegate: on an NSTextField, such that a delegate method would be called when I typed in the text field.  I  looked through the documentation, and I decided to to see if implementing this delegate method would work:
    - (BOOL)control:(NSControl *)control textShouldBeginEditing:(NSText *)fieldEditor;
    I created a new app(deleting the classes that Xcode automatically creates, as well as the instance in the MainWindow.xib window in IB), and then I created this class:
    //MyDelegate.h
    import <Cocoa/Cocoa.h>
    @interface MyDelegate : NSObject <NSTextFieldDelegate> {
    - (BOOL)control:(NSControl *)control
              textShouldBeginEditing:(NSText *)fieldEditor;
    @end
    //MyDelegate.m
    @implementation MyDelegate
    - (BOOL)control:(NSControl *)control
                   textShouldBeginEditing:(NSText *)fieldEditor
              NSLog(@"***In delegate method...");
              return YES;
    @end
    1) In IB, I created an instance of MyDelegate by dragging an Object from the Library onto the MainWindow.xib window.  I entered the name MyDelegate in the TextField Identity Inspector.
    2) In IB, I ctrl-clicked on the NSTextField, and then I dragged a connection from NSTextField's 'delegate' outlet to the MyDelegate instance(in the MainWindow.xib window).
    3) Saved everything, build&run, and when I typed in the text field, I saw the logged message in the Debugger Console, as expected.
    Next, I attempted to create code that uses setDelegate: to achieve the same thing as above.
    4) In IB, I ctrl-clicked on the NSTextField and deleted the connection from the 'delegate' outlet to the MyDelegate instance.
    5)  I made these changes to the code:
    //MyDelegate.h
    #import <Cocoa/Cocoa.h>
    @interface MyDelegate : NSObject <NSTextFieldDelegate> {
              IBOutlet NSTextField* textField;
    - (id)init;
    - (BOOL)control:(NSControl *)control
              textShouldBeginEditing:(NSText *)fieldEditor;
    @end
    //MyDelegate.m
    #import "MyDelegate.h"
    @implementation MyDelegate
    - (id) init
              if (![super init]) {
                        return nil;
              [textField setDelegate:self];
              return self;
    - (BOOL)control:(NSControl *)control
              textShouldBeginEditing:(NSText *)fieldEditor
              NSLog(@"***In delegate method...");
              return YES;
    @end
    6) In IB, I ctrl-clicked on the MyDelegate instance in the MainWindow.xib window, and then I dragged a connection from the outlet 'textField' to the NSTextField(in the app's main window).
    7) I saved in IB, then build&run (save everything), and this time when I typed in the textfield, the message was not logged to the Debug Console.
    What is the matter with setDelegate:?  Why doesn't setDelegate: succeed in setting up the delegate so that I can see the message logged to the console?
    Thanks

  • Hours entered by delegate in time sheet not reflecting in reports

    This is for Project Server 2013. Even I have faced this issues in PS 2010 and it still continues.
    There are 2 users. user A and user B. User A is on leave and User B has been set up as a delegate to fill out time sheets for user A. User B logs in and acts a a delegate for user A. He fills up A's timesheet and submits. Project manager receives task updates
    for A and approves. Project plan is published. But hours for user A are not reflecting is Time sheet reports.
    Abhijeet, MCTS | [email protected]

    Hi Abhijeet,
    Can't say here about delegation, but yes I have faced one issue where timesheet data was not getting synch with Reporting DB.
    So to fix this please follow steps.
    1) Recall the problematic timesheet.
    2) Do some minor change.
    3) Then revert those changes.
    4)Then first click on "Save"
    5) And at last "Submit" the timesheet.
    Don't know exactly what was the reason for particular timesheets, "Reporting Timesheet Save" job was not getting fired whenever user is submitting the timesheet.
    Using above mentioned steps helped to get my timesheet data get synch with Reporting DB.
    Hope it will work for you as well.
    Thanks !!!!
    Sachin Vashishth MCTS

  • Time sheets submitted as delegate

    This is for Project Server 2013. Even I have faced this issues in PS 2010 and it still continues.
    There are 2 users. user A and user B. User A is on leave and User B has been set up as a delegate to fill out time sheets for user A. User B logs in and acts a a delegate for user A. He fills up A's timesheet and submits. Project manager receives task updates
    for A and approves. Project plan is published. But hours for user A are not reflecting is Time sheet reports.
    Abhijeet, MCTS | [email protected]

    Hi Abhijeet,
    What do you mean exactly by "timesheet reports"? Are you using OLAP cubes, Reporting DB...?
    Then have you check in the queue and ULS log that all jobs related to your process (espacially approval and publish jobs) have been successfully processed?
    Before checking your reports, I'd suggest to check first the project plan in Project Pro to see if the actuals have correctly been updated from timesheet approval. Then I'd check publish and reporting DB to ensure the data are correct.
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • Delegate Control (AdditionalPageHead) rendering...but when?

    Hi,
    can someone tell when a Delegate Control (AdditionalPageHead) is rendering?

    It renders in the Initialization Page Lifecycle event,
    In the v4.master page, in the additonal head place holder, there is a delegate control, literally SharePoint:Delegatecontrol... etc defined in the markup.  it has an ID of AdditionalPageHead.
    When the delegate control loads in the Initialization lifecycle event, it goes through the Features folder in the 14 hive and looks for Element.xml files that define <Control.. nodes.
    If the control nodes ControlID is set to AdditionalPageHead, the delegate caches them, and then initializes the control the Control node references in the order of their
    Sequence.  The control node with the lowest Sequence gets initialized first.
    Any control loaded via that delegate control should be available in a child controls CreateChildControls method, assuming you did base.CreateChildControls() first.  Any script output in an ascx control loaded by that delegate control should render in the
    page head of a page at the end of the page head.  The delegate control is declared after the ootb sharepoint scrip and css includes, so anything you deploy to that delegate control should have all the ootb javascript available and you can use ExecuteOrDelayUntilScriptLoaded
    to wait for a sharepoint java api to finish loading (they load dynamically).
    Additionally, if you need a control to load in a delegate control someplace else, you can edit the master page for a site and add your own delegate control place holder.
    My Blog: http://www.thesug.org/Blogs/ryan_mann1/default.aspx Website: Under Construction

  • Couldn't parse image from XML file using NSXMLParser

    Hi all, Since i am newbie to developing iPhone application, i have problem in parsing XML data.
    I use the following code for parsing XML file, this is RootViewController.h file
    #import <UIKit/UIKit.h>
    #import "SlideMenuView.h"
    #define kNameValueTag 1
    #define kColorValueTag 2
    #define kSwitchTag 100
    @class DetailViewController;
    @interface RootViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
    DetailViewController *detailViewController;
    UITableView *myTable;
    UIActivityIndicatorView *activityIndicator;
    UIButton *btn;
    CGSize cellSize;
    NSXMLParser *rssParser;
    NSMutableArray *stories;
    NSMutableDictionary *item;
    NSString *currentElement;
    NSMutableString *currentTitle, *currentDate, *currentSummary, *currentLink, *currentImage;
    SlideMenuView *slideMenu;
    NSMutableArray *buttonArray;
    UIButton *rubic;
    UIButton *buurt;
    UIButton *beeld;
    UILabel *lbl;
    NSString *url;
    @property (nonatomic, retain) UITableView *myTable;
    @property (nonatomic, retain) DetailViewController *detailViewController;
    @property (nonatomic, retain) SlideMenuView *slideMenu;
    @property (nonatomic, retain) UIButton *btn;
    @property (nonatomic, retain) NSMutableArray *buttonArray;
    @property (nonatomic, retain) UIButton *rubic;
    @property (nonatomic, retain) UIButton *buurt;
    @property (nonatomic, retain) UIButton *beeld;
    @property (nonatomic, retain) UILabel *lbl;
    @end
    below is the RootViewController.m file,
    #import <Foundation/Foundation.h>
    #import "RootViewController.h"
    #import "DetailViewController.h"
    #import "SlideMenuView.h"
    @implementation RootViewController
    @synthesize rubic, buurt, beeld, detailViewController, myTable, btn, buttonArray, slideMenu, lbl;
    - (void)parseXMLFileAtURL:(NSString *)URL {
    stories = [[NSMutableArray alloc] init];
    //you must then convert the path to a proper NSURL or it won't work
    NSURL *xmlURL = [NSURL URLWithString:URL];
    // here, for some reason you have to use NSClassFromString when trying to alloc NSXMLParser, otherwise you will get an object not found error
    // this may be necessary only for the toolchain
    rssParser = [[NSXMLParser alloc] initWithContentsOfURL:xmlURL];
    // Set self as the delegate of the parser so that it will receive the parser delegate methods callbacks.
    [rssParser setDelegate:self];
    // Depending on the XML document you're parsing, you may want to enable these features of NSXMLParser.
    [rssParser setShouldProcessNamespaces:NO];
    [rssParser setShouldReportNamespacePrefixes:NO];
    [rssParser setShouldResolveExternalEntities:NO];
    [rssParser parse];
    - (void)parser:(NSXMLParser *)parser parseErrorOccurred:(NSError *)parseError {
    NSString * errorString = [NSString stringWithFormat:@"Unable to download story feed from web site (Error code %i )", [parseError code]];
    NSLog(@"error parsing XML: %@", errorString);
    UIAlertView * errorAlert = [[UIAlertView alloc] initWithTitle:@"Error loading content" message:errorString delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [errorAlert show];
    - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict{
    //NSLog(@"found this element: %@", elementName);
    currentElement = [elementName copy];
    if ([elementName isEqualToString:@"item"]) {
    // clear out our story item caches...
    item = [[NSMutableDictionary alloc] init];
    currentTitle = [[NSMutableString alloc] init];
    currentDate = [[NSMutableString alloc] init];
    currentSummary = [[NSMutableString alloc] init];
    currentLink = [[NSMutableString alloc] init];
    currentImage = [[NSMutableString alloc] init];
    - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName{
    //NSLog(@"ended element: %@", elementName);
    if ([elementName isEqualToString:@"item"]) {
    // save values to an item, then store that item into the array...
    [item setObject:currentTitle forKey:@"title"];
    [item setObject:currentSummary forKey:@"summary"];
    [item setObject:currentDate forKey:@"date"];
    [item setObject:currentImage forKey:@"enclosure"];
    [stories addObject:[item copy]];
    NSLog(@"adding story: %@", currentTitle);
    - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string{
    //NSLog(@"found characters: %@", string);
    // save the characters for the current item...
    if ([currentElement isEqualToString:@"title"]) {
    [currentTitle appendString:string];
    } else if ([currentElement isEqualToString:@"description"]) {
    [currentSummary appendString:string];
    } else if ([currentElement isEqualToString:@"pubDate"]) {
    [currentDate appendString:string];
    } else if ([currentElement isEqualToString:@"enclosure"]) {
    [currentImage appendString:string];
    - (void)parserDidEndDocument:(NSXMLParser *)parser {
    [activityIndicator stopAnimating];
    [activityIndicator removeFromSuperview];
    NSLog(@"all done!");
    NSLog(@"stories array has %d items", [stories count]);
    [myTable reloadData];
    - (void)loadView {
    //self.title = @"GVA_iPhone";
    //UIImage *img = [UIImage imageNamed: @"gva_v2.1.png"];
    CGRect frame = [[UIScreen mainScreen] bounds];
    UIView *aView = [[UIView alloc] initWithFrame:frame];
    aView.backgroundColor = [UIColor grayColor];
    self.view = aView;
    [aView release];
    lbl = [[UILabel alloc] initWithFrame:CGRectMake(0.0, 33.0, 320.0, 30.0)];
    lbl.backgroundColor = [UIColor colorWithRed:21.0/255.0 green:113.0/255.0 blue:194.0/255.0 alpha:1.0];
    lbl.textColor = [UIColor whiteColor];
    lbl.font = [UIFont boldSystemFontOfSize:18.0];
    [self.view addSubview:lbl];
    [lbl release];
    buttonArray = [[NSMutableArray alloc] init];
    for(int i = 1; i < 4; i++)
    // Rounded rect is nice
    //UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    // Give the buttons a width of 100 and a height of 30. The slide menu will take care of positioning the buttons.
    // If you don't know that 100 will be enough, use my function to calculate the length of a string. You find it on my blog.
    [btn setFrame:CGRectMake(0.0f,3.0f, 120.0f, 30.0f)];
    switch(i){
    case 1:
    [btn setTitle:[NSString stringWithFormat:@" Snel", i+1] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
    lbl.text = @" Snel";
    [btn addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
    [buttonArray addObject:btn];
    break;
    case 2:
    [btn setTitle:[NSString stringWithFormat:@" Binnenland", i+1] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
    [buttonArray addObject:btn];
    break;
    case 3:
    [btn setTitle:[NSString stringWithFormat:@" Buitenland", i+1] forState:UIControlStateNormal];
    [btn setBackgroundImage:[UIImage imageNamed:@"topbg02.png"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(buttonTouched:) forControlEvents:UIControlEventTouchUpInside];
    [buttonArray addObject:btn];
    break;
    [btn release];
    slideMenu = [[SlideMenuView alloc]initWithFrameColorAndButtons:CGRectMake(0.0, 3.0, 330.0, 30.0) backgroundColor:[UIColor blackColor] buttons:buttonArray];
    [self.view addSubview:slideMenu];
    UITableView *aTableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 63.0, 320.0, 310.0)];
    aTableView.dataSource = self;
    aTableView.delegate = self;
    aTableView.rowHeight = 120;
    self.myTable = aTableView;
    [aTableView release];
    [self.view addSubview:myTable];
    rubic = [[UIButton alloc]initWithFrame:CGRectMake(0.0, 370.0, 105.0, 50.0)];
    [rubic setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [rubic setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
    [rubic addTarget:self action:@selector(buttonBinn:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:rubic];
    UILabel *lblRub = [[UILabel alloc]initWithFrame:CGRectMake(10.0, 385.0, 45.0, 12.0)];
    lblRub.text = @"Rubriek";
    lblRub.font = [UIFont boldSystemFontOfSize:11.0];
    lblRub.backgroundColor = [UIColor clearColor];
    lblRub.textColor = [UIColor whiteColor];
    [self.view addSubview:lblRub];
    UIImageView *imgCat = [[UIImageView alloc] initWithFrame:CGRectMake(58.0, 375.0, 39.0, 36.0)];
    imgCat.image = [UIImage imageNamed:@"category_icon.png"];
    [self.view addSubview:imgCat];
    buurt = [[UIButton alloc] initWithFrame:CGRectMake(105.0, 370.0, 108.0, 50.0)];
    [buurt setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    [buurt addTarget:self action:@selector(buttonBuurt:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buurt];
    UILabel *lblGlo = [[UILabel alloc]initWithFrame:CGRectMake(112.0, 385.0, 59.0, 12.0)];
    lblGlo.text = @"In de Buurt";
    lblGlo.font = [UIFont boldSystemFontOfSize:11.0];
    lblGlo.backgroundColor = [UIColor clearColor];
    lblGlo.textColor = [UIColor whiteColor];
    [self.view addSubview:lblGlo];
    UIImageView *imgGlo = [[UIImageView alloc] initWithFrame:CGRectMake(173.0, 375.0, 39.0, 36.0)];
    imgGlo.image = [UIImage imageNamed:@"globe_icon.png"];
    [self.view addSubview:imgGlo];
    beeld = [[UIButton alloc]initWithFrame:CGRectMake(213.0, 370.0, 108.0, 50.0)];
    [beeld setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    [beeld addTarget:self action:@selector(buttonBeeld:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:beeld];
    UILabel *lblCam = [[UILabel alloc]initWithFrame:CGRectMake(228.0, 385.0, 45.0, 12.0)];
    lblCam.text = @"In Beeld";
    lblCam.font = [UIFont boldSystemFontOfSize:11.0];
    lblCam.backgroundColor = [UIColor clearColor];
    lblCam.textColor = [UIColor whiteColor];
    [self.view addSubview:lblCam];
    UIImageView *imgCam = [[UIImageView alloc] initWithFrame:CGRectMake(276.0, 375.0, 39.0, 36.0)];
    imgCam.image = [UIImage imageNamed:@"camera_icon.png"];
    [self.view addSubview:imgCam];
    if([stories count] == 0) {
    [self parseXMLFileAtURL:@"http://iphone.concentra.exuvis.com/feed/rss/article/2/binnenland.xml"];
    cellSize = CGSizeMake([myTable bounds].size.width,60);
    - (IBAction)buttonPressed:(id)sender {
    lbl.text = ((UIButton*)sender).currentTitle;
    - (IBAction)buttonClicked:(id)sender {
    lbl.text = ((UIButton*)sender).currentTitle;
    - (IBAction)buttonTouched:(id)sender {
    lbl.text = ((UIButton*)sender).currentTitle;
    -(void)buttonBinn:(id)sender
    [rubic setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
    [buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    [beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    -(void)buttonBuurt:(id)sender
    [buurt setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
    [beeld setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    [rubic setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    -(void)buttonBeeld:(id)sender
    [beeld setBackgroundImage:[UIImage imageNamed:@"MOUSEOVER.png"] forState:UIControlStateNormal];
    [rubic setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    [buurt setBackgroundImage:[UIImage imageNamed:@"bottombg01.png"] forState:UIControlStateNormal];
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
    - (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
    - (void)dealloc {
    [myTable release];
    [detailViewController release];
    [super dealloc];
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [stories count];
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"GVAiPhone"];
    if (cell == nil) {
    //CGRect cellFrame = CGRectMake(0, 0, 300, 65);
    cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"GVAiPhone"] autorelease];
    //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    //cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
    CGRect nameValueRect = CGRectMake(5, 5, 275, 35);
    UILabel *nameValue = [[UILabel alloc] initWithFrame:nameValueRect];
    nameValue.tag = kNameValueTag;
    nameValue.font = [UIFont fontWithName:@"Arial" size:15.0];
    nameValue.lineBreakMode = UILineBreakModeWordWrap;
    nameValue.numberOfLines = 2;
    [cell.contentView addSubview:nameValue];
    [nameValue release];
    CGRect colorValueRect = CGRectMake(5, 38, 275, 65);
    UILabel *colorValue = [[UILabel alloc] initWithFrame:colorValueRect];
    colorValue.tag = kColorValueTag;
    colorValue.font = [UIFont fontWithName:@"Arial" size:11.0];
    colorValue.textColor = [UIColor colorWithRed:130.0/255.0 green:135.0/255.0 blue:139.0/255.0 alpha:1.0];
    colorValue.lineBreakMode = UILineBreakModeWordWrap;
    colorValue.textAlignment = UITextAlignmentLeft;
    colorValue.numberOfLines = 6;
    [cell.contentView addSubview:colorValue];
    [colorValue release];
    // Set up the cell
    //cell.text = [theSimpsons objectAtIndex:indexPath.row];
    //cell.hidesAccessoryWhenEditing = YES;
    NSUInteger storyIndex = [indexPath row];
    NSDictionary *rowData = [stories objectAtIndex:storyIndex];
    UILabel *name = (UILabel *)[cell.contentView viewWithTag:kNameValueTag];
    name.text = [rowData objectForKey:@"title"];
    //name.lineBreakMode;
    //UIImage *image =[UIImage imageNamed: currentImage];imageWithContentsOfFile
    //image.size.width = 50;
    //iimage.size.height = 50;
    //cell.image = [UIImage imageNamed:currentImage];
    cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"arrow_icon.png"]];
    UILabel *color = (UILabel *)[cell.contentView viewWithTag:kColorValueTag];
    color.text = [rowData objectForKey:@"summary"];
    return cell;
    @end
    - here the actual problem is the xml node <enclosure> contains images but in using the method "didEndElement" , it doesn't parse into the <enclosure> node. ya so please help me in parsing and getting the image.
    Waiting for your help !!
    -Sathiya

    Hi, how did you solve your problem in detail. I'm having the same problem with this rss-feed: www.spiegel.de/index.rss
    I cannot parse the url of the images. I'm looking forward to your answer.

  • Problem with XMLEncoder for complex java object i

    Hi All.
    My problem with XMLEncoder is it doesnt transfrom java objects without default no arguement constructor. I was able to resolve this in my main java object class, by setting a new persistence delegate, but for other classes that are contained in the main class, they are not being encoded.
    Thanks in advance for your answers

    Better to put this in java forum :-)
    Just check, if this helps.
    http://forum.java.sun.com/thread.jspa?threadID=379614&messageID=1623434

Maybe you are looking for

  • Windows Media Player Classic in Adobe Reader X

    Every time when i want to play a video in (PDF file) Adobe Reader X it wants to play it with Windows media player classic. And the only thing adobe reader shows me is the logo from WMPC, it wont play the video. The video files are .wmv so that can't

  • Why wont dictation for mac turn on?

    i have macbook pro 13" that i bought brand new at future shop last fall (fall 2011), and i just paid to upgrade my OS X to mountain lion and from the start after the download was done and the computer did it's restart, when i go into my settings to t

  • CSS not displaying properly

    My CSS file includes the following formatting for a "Note": p.Note { border-left-style: Solid; border-right-style: Solid; border-top-style: Solid; border-bottom-style: Solid; background-color: #fafade; padding-left: 12px; padding-right: 12px; padding

  • Joins for OKS (Billing) tables

    Hi, A couple of questions: 1) Can anyone let me know how the following tables can be joined correctly with OKC_K_LINES_B? If there is more than one way, please let me know that too: OKS_BILL_CONT_LINES OKS_BILL_SUB_LINES OKS_BILL_SUB_LINE_DTLS OKS_BI

  • Issue while using views in Data services Jobs

    Hi, In Data Services Job, i am trying to pull data from a view to a table. The view is pointing to the table which is in other database. The problem is when i import the source view into data services and view the data, i found one row having wrong d