简体   繁体   中英

inAppbrowser done button text change

in my phonegap iOS app, im using cordova2.7.0 and using inAppwebbrowser, when it opens done button coming to bottom, i need to chnge text of 'Done' to french name, so please tell me.

Thanks

You can do it by native in Xcode ,in phonegap currently can't do it , customizing 'Done' button text is a feature that the Phonegap team is working on. You can read more about it here .

how in xcode:

Locate CDVInAppBrowser.m as shown

coredovalib -> classes -> commands -> CDVInAppBrowser.m 

and paste below code snippet where close button properties are set

    self.closeButton = [[UIBarButtonItem alloc] initWithTitle:@"my text"
 style:UIBarButtonItemStyleBordered target:self action:@selector(close)];

Try this

On CDVInAppBrowser.m file replace

Replace this

 if (browserOptions.closebuttoncaption != nil) {
       [self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
  }

to

if (browserOptions.closebuttoncaption == nil) {
    NSLog(@"hiii if");
    [self.inAppBrowserViewController setCloseButtonTitle:@"Your French Name hear"];
}

Open ${projectname}/plugins/org.apache.cordova.inappbrowser/src/ios/CDVInAppBrowser.m with an editor of your choice.

in the init function, look for this:

self.toolbar = YES;
self.closebuttoncaption = nil;
self.toolbarposition = kInAppBrowserToolbarBarPositionBottom;
self.clearcache = NO;
self.clearsessioncache = NO;

Change self.closebuttoncaption = nil; => self.closebuttoncaption = @"your text";

The Main advantage here is that it builds correct and you don't have to change it every time you build. Also it is recommend to change the text in the init function, so don't have to change it in the setter function.

PS: Im using org.apache.cordova.inappbrowser 0.6.0 "InAppBrowser"

In Cordova InAppBrowser 1.7.0 you can supply the close button text as closebuttoncaption when calling the InAppBrowser rather than having to change the code of Cordova:

myIAB.create('http:/blah, '_blank', 'location=no,closebuttoncaption=Close');

And also in window.open :

window.open('http://blah','_blank','location=no,closebuttoncaption=Close');

Other browserOptions listed in CDVInAppBrowserOptions with the defaults:

location = YES;
toolbar = YES;
closebuttoncaption = nil;
toolbarposition = kInAppBrowserToolbarBarPositionBottom;
clearcache = NO;
clearsessioncache = NO;
enableviewportscale = NO;
mediaplaybackrequiresuseraction = NO;
allowinlinemediaplayback = NO;
keyboarddisplayrequiresuseraction = YES;
suppressesincrementalrendering = NO;
hidden = NO;
disallowoverscroll = NO;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM