• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NSString类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.robovm.apple.foundation.NSString的典型用法代码示例。如果您正苦于以下问题:Java NSString类的具体用法?Java NSString怎么用?Java NSString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NSString类属于org.robovm.apple.foundation包,在下文中一共展示了NSString类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: add

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
private void add() {
	// bmob
	Bmob.registerWithAppKey("34b7704a3b372576a732b7675abce9e8");
	// Gdx.app.log("xxx", "showInterAd");
	System.out.println("showInterAd");
	final BmobObject gameScore = new BmobObject("GameScore");
	gameScore.setObject(new NSString("小明"), "playerName");
	gameScore.setObject(NSNumber.valueOf(100), "playerScore");
	gameScore.setObject(NSNumber.valueOf(true), "cheatMode");

	gameScore.saveInBackgroundWithResultBlock(new BmobBooleanResultBlock() {
		@Override
		public void invoke(boolean isSuccessful, NSError error) {
			if (isSuccessful) {
				System.out.println("success");
				System.out.println(gameScore.getObjectId());
				System.out.println(Bmob.getServerTimestamp());
				query();
			} else {
				System.out.println(error.getErrorCode() + error.getDomain());
			}
		}
	});
	System.out.println("showInterAd ---- end");
}
 
开发者ID:tianqiujie,项目名称:robovm-ios-bindings,代码行数:26,代码来源:IOSLauncher.java


示例2: getPreferences

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public Preferences getPreferences (String name) {
	File libraryPath = new File(System.getenv("HOME"), "Library");
	File finalPath = new File(libraryPath, name + ".plist");

	@SuppressWarnings("unchecked")
	NSMutableDictionary<NSString, NSObject> nsDictionary = (NSMutableDictionary<NSString, NSObject>)NSMutableDictionary
		.read(finalPath);

	// if it fails to get an existing dictionary, create a new one.
	if (nsDictionary == null) {
		nsDictionary = new NSMutableDictionary<NSString, NSObject>();
		nsDictionary.write(finalPath, false);
	}
	return new IOSPreferences(nsDictionary, finalPath.getAbsolutePath());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:IOSApplication.java


示例3: didFinishLaunching

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public boolean didFinishLaunching(UIApplication application,
		NSDictionary<NSString, ?> launchOptions) {
	
	window = new UIWindow(UIScreen.getMainScreen().getBounds());

	GenderListTableViewController genderListTableViewController = new GenderListTableViewController();
	UINavigationController navigationController = new UINavigationController(genderListTableViewController);
	navigationController.addStrongRef(genderListTableViewController);
	navigationController.setDelegate(new UINavigationControllerDelegateAdapter() {});
	window.setRootViewController(navigationController);
	window.setBackgroundColor(UIColor.colorWhite());
	window.makeKeyAndVisible();

	return true;
}
 
开发者ID:Kourtessia,项目名称:RoboVM-for-iOS,代码行数:17,代码来源:RoboVMTableViewApplicationDelegate.java


示例4: viewWillAppear

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public void viewWillAppear(boolean animated) {
    super.viewWillAppear(animated);

    FacebookHandler.getInstance().requestFriends(new FacebookHandler.RequestListener() {
        @SuppressWarnings("unchecked")
        @Override
        public void onSuccess(NSObject result) {
            FacebookHandler.log("Friends result: %s", result);

            NSDictionary<NSString, ?> root = (NSDictionary<NSString, ?>) result;
            friends = (NSArray<NSDictionary<NSString, ?>>) root
                    .get(new NSString("data"));
            getTableView().reloadData();
        }

        @Override
        public void onError(String message) {
            FacebookHandler.getInstance().alertError("Error while getting a list of your friends!", message);
        }

        @Override
        public void onCancel() {}
    });
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:FriendsViewController.java


示例5: getHeightForCell

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
public static double getHeightForCell(String name, String content, double cellInset) {
    CGSize nameSize = NSString.getBoundingRect(name, new CGSize(200, Float.MAX_VALUE),
            NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                    NSStringDrawingOptions.UsesLineFragmentOrigin),
            new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();

    String paddedString = padString(content, UIFont.getSystemFont(13), nameSize.getWidth());
    double horizontalTextSpace = getHorizontalTextSpaceForInsetWidth(cellInset);

    CGSize contentSize = NSString.getBoundingRect(paddedString, new CGSize(horizontalTextSpace, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize();

    double singleLineHeight = NSString.getBoundingRect("test", new CGSize(Float.MAX_VALUE, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize().getHeight();

    // Calculate the added height necessary for multiline text. Ensure value
    // is not below 0.
    double multilineHeightAddition = contentSize.getHeight() - singleLineHeight;

    return 58 + Math.max(0, multilineHeightAddition);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:24,代码来源:PAPActivityCell.java


示例6: getHeightForCell

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
public static double getHeightForCell(String name, String content, double cellInset) {
    CGSize nameSize = NSString.getBoundingRect(name, new CGSize(200, Float.MAX_VALUE),
            NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                    NSStringDrawingOptions.UsesLineFragmentOrigin),
            new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();

    String paddedString = padString(content, UIFont.getSystemFont(13), nameSize.getWidth());
    double horizontalTextSpace = getHorizontalTextSpaceForInsetWidth(cellInset);

    CGSize contentSize = NSString.getBoundingRect(paddedString, new CGSize(horizontalTextSpace, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize();

    double singleLineHeight = NSString.getBoundingRect("test", new CGSize(Float.MAX_VALUE, Float.MAX_VALUE),
            NSStringDrawingOptions.UsesLineFragmentOrigin,
            new NSAttributedStringAttributes().setFont(UIFont.getSystemFont(13)), null).getSize().getHeight();

    // Calculate the added height necessary for multiline text. Ensure value
    // is not below 0.
    double multilineHeightAddition = (contentSize.getHeight() - singleLineHeight) > 0 ? (contentSize.getHeight() - singleLineHeight)
            : 0;

    return HORI_BORDER_SPACING + AVATAR_DIM + HORI_BORDER_SPACING_BOTTOM + multilineHeightAddition;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:25,代码来源:PAPBaseTextCell.java


示例7: padString

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
protected static String padString(String string, UIFont font, double width) {
    // Find number of spaces to pad
    StringBuilder sb = new StringBuilder();
    CGSize size = new CGSize(Float.MAX_VALUE, Float.MAX_VALUE);
    NSStringDrawingOptions options = NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
            NSStringDrawingOptions.UsesLineFragmentOrigin);
    NSAttributedStringAttributes attr = new NSAttributedStringAttributes().setFont(font);
    while (true) {
        sb.append(" ");
        CGSize resultSize = NSString.getBoundingRect(sb.toString(), size, options, attr, null).getSize();
        if (resultSize.getWidth() >= width) {
            break;
        }
    }

    // Add final spaces to be ready for first word
    sb.append(String.format(" %s", string));
    return sb.toString();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:PAPBaseTextCell.java


示例8: setContentText

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
public void setContentText(String contentString) {
    // If we have a user we pad the content with spaces to make room for the
    // name
    if (user != null) {
        CGSize nameSize = NSString.getBoundingRect(
                nameButton.getTitleLabel().getText(),
                new CGSize(NAME_MAX_WIDTH, Float.MAX_VALUE),
                NSStringDrawingOptions.with(NSStringDrawingOptions.TruncatesLastVisibleLine,
                        NSStringDrawingOptions.UsesLineFragmentOrigin),
                new NSAttributedStringAttributes().setFont(UIFont.getBoldSystemFont(13)), null).getSize();
        String paddedString = padString(contentString, UIFont.getSystemFont(13), nameSize.getWidth());
        contentLabel.setText(paddedString);
    } else {
        // Otherwise we ignore the padding and we'll add it after we set the
        // user
        contentLabel.setText(contentString);
    }
    setNeedsDisplay();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:PAPBaseTextCell.java


示例9: getCellForRow

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public UITableViewCell getCellForRow(UITableView tableView, NSIndexPath indexPath) {
    UITableViewCell cell = null;
    String localizedTitle = null;

    if (indexPath.getSection() == 0) {
        cell = tableView.dequeueReusableCell(AllPhotosReuseIdentifier, indexPath);
        localizedTitle = NSString.getLocalizedString("All Photos");
    } else {
        cell = tableView.dequeueReusableCell(CollectionCellReuseIdentifier, indexPath);
        PHFetchResult<? extends PHCollection> fetchResult = collectionsFetchResults.get(indexPath.getSection() - 1);
        PHCollection collection = fetchResult.get(indexPath.getRow());
        localizedTitle = collection.getLocalizedTitle();
    }
    cell.getTextLabel().setText(localizedTitle);

    return cell;
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:AAPLRootListViewController.java


示例10: updateBatteryLevel

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
private void updateBatteryLevel() {
    float batteryLevel = UIDevice.getCurrentDevice().getBatteryLevel();
    if (batteryLevel < 0) {
        // -1.0 means battery state is UIDeviceBatteryState.Unknown
        levelLabel.setText(NSString.getLocalizedString("Unknown"));
    } else {
        NSNumberFormatter numberFormatter = null;
        if (numberFormatter == null) {
            numberFormatter = new NSNumberFormatter();
            numberFormatter.setNumberStyle(NSNumberFormatterStyle.Percent);
            numberFormatter.setMaximumFractionDigits(1);
        }

        NSNumber levelObj = NSNumber.valueOf(batteryLevel);
        levelLabel.setText(numberFormatter.format(levelObj));
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:BatStatViewController.java


示例11: fetchProductInformation

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
/** Retrieve product information from the App Store */
@SuppressWarnings("unchecked")
private void fetchProductInformation() {
    // Query the App Store for product information if the user is is allowed
    // to make purchases.
    // Display an alert, otherwise.
    if (SKPaymentQueue.canMakePayments()) {
        // Load the product identifiers fron ProductIds.plist
        String filePath = NSBundle.getMainBundle().findResourcePath("ProductIds", "plist");
        NSArray<NSString> productIds = (NSArray<NSString>) NSArray.read(new File(filePath));

        StoreManager.getInstance().fetchProductInformationForIds(productIds.asStringList());
    } else {
        // Warn the user that they are not allowed to make purchases.
        alert("Warning", "Purchases are disabled on this device.");
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:18,代码来源:IOSProductsList.java


示例12: prepareForSegue

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public void prepareForSegue(UIStoryboardSegue segue, NSObject sender) {
    if (shortcutItem == null) {
        throw new RuntimeException("shortcutItem was not set");
    }

    if (segue.getIdentifier().equals("ShortcutDetailUpdated")) {
        // In the updated case, create a shortcut item to represent the
        // final state of the view controller.
        UIApplicationShortcutIconType iconType = getIconTypeForSelectedRow((int) pickerView.getSelectedRow(0));

        UIApplicationShortcutIcon icon = new UIApplicationShortcutIcon(iconType);

        NSDictionary<NSString, ?> info = new NSMutableDictionary<>();
        info.put(ApplicationShortcuts.APPLICATION_SHORTCUT_USER_INFO_ICON_KEY, pickerView.getSelectedRow(0));
        shortcutItem = new UIApplicationShortcutItem(shortcutItem.getType(), titleTextField.getText(),
                subtitleTextField.getText(), icon, info);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:20,代码来源:ShortcutDetailViewController.java


示例13: fireProjectile

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
private void fireProjectile () {
    APAMultiplayerLayeredCharacterScene scene = getCharacterScene();

    SKSpriteNode projectile = (SKSpriteNode)getProjectile().copy();
    projectile.setPosition(getPosition());
    projectile.setZRotation(getZRotation());

    SKEmitterNode emitter = (SKEmitterNode)getProjectileEmitter().copy();
    emitter.setTargetNode(scene.getChild("world"));
    projectile.addChild(emitter);

    scene.addNode(projectile, APAWorldLayer.Character);

    double rot = getZRotation();

    projectile.runAction(SKAction.moveBy(-Math.sin(rot) * HERO_PROJECTILE_SPEED * HERO_PROJECTILE_LIFETIME, Math.cos(rot)
        * HERO_PROJECTILE_SPEED * HERO_PROJECTILE_LIFETIME, HERO_PROJECTILE_LIFETIME));
    projectile.runAction(SKAction.sequence(new NSArray<SKAction>(SKAction.wait(HERO_PROJECTILE_FADEOUT_TIME), SKAction
        .fadeOut(HERO_PROJECTILE_LIFETIME - HERO_PROJECTILE_FADEOUT_TIME), SKAction.removeFromParent())));
    projectile.runAction(sharedProjectileSoundAction);

    NSMutableDictionary<NSString, NSObject> userData = new NSMutableDictionary<>();
    userData.put(PLAYER_KEY, player);
    projectile.setUserData(userData);
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:26,代码来源:APAHeroCharacter.java


示例14: populateRegistrationDomain

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
/**
 * Locates the file representing the root page of the settings for this app,
 * invokes loadDefaults:fromSettingsPage:inSettingsBundleAtURL: on it, and
 * registers the loaded values as the app's defaults.
 */
private void populateRegistrationDomain() {
    NSURL settingsBundleURL = NSBundle.getMainBundle().findResourceURL("Settings", "bundle");

    /*
     * Invoke loadDefaults() on the property list file for the root settings
     * page (always named Root.plist).
     */
    NSDictionary<NSString, ?> appDefaults = loadDefaults("Root.plist", settingsBundleURL);

    /*
     * appDefaults is now populated with the preferences and their default
     * values. Add these to the registration domain.
     */
    NSUserDefaults.getStandardUserDefaults().registerDefaults(appDefaults);
    NSUserDefaults.getStandardUserDefaults().synchronize();
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:22,代码来源:AppPrefs.java


示例15: viewDidLoad

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public void viewDidLoad() {
    super.viewDidLoad();

    try {
        // Load the display strings.
        String resourcePath = NSBundle.getMainBundle().findResourcePath("DisplayStrings", "txt");
        String string = NSString.readFile(resourcePath, NSStringEncoding.UTF16BigEndian);

        if (string != null) {
            String[] displayStrings = string.split("\\r?\\n");
            moveMeView.setDisplayStrings(displayStrings);
            moveMeView.setupNextDisplayString();
        }
    } catch (NSErrorException e) {
        throw new Error(e);
    }
}
 
开发者ID:robovm,项目名称:robovm-samples,代码行数:19,代码来源:APLViewController.java


示例16: getSize

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
private CGRect getSize(String text) {

        NSString nsString = new NSString(text);
        UIFont uiFont = UIFont.getFont("Helvetica", 15);

        NSAttributedStringAttributes attribs = new NSAttributedStringAttributes();
        attribs.setFont(uiFont);
        CGSize bounding = nsString.getSize(attribs);

        double ext = (uiFont.getLineHeight() * 2);

        double height = Math.max(bounding.getHeight() + ext, this.getBounds().getHeight() - this.okButton.getBounds().getHeight());
        double width = Math.max(bounding.getWidth() + ext, this.getBounds().getWidth());
        return new CGRect(0, 0, width, height);
    }
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:16,代码来源:IOS_TextInputView.java


示例17: change

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
private void change(final BmobObject object) {
	BmobObject obj = BmobObject.objectWithoutDatatWithClassName(
			object.getClassName(), object.getObjectId());
	obj.setObject(new NSString("改过的小明"), "playerName");
	obj.updateInBackgroundWithResultBlock(new BmobBooleanResultBlock() {

		@Override
		public void invoke(boolean isSuccessful, NSError error) {
			// TODO Auto-generated method stub
			System.out.println("修改成功....");

			delete(object);
		}
	});
}
 
开发者ID:tianqiujie,项目名称:robovm-ios-bindings,代码行数:16,代码来源:IOSLauncher.java


示例18: didFinishLaunching

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public boolean didFinishLaunching(UIApplication application,
		UIApplicationLaunchOptions launchOptions) {

	MobClick.startWithAppkey("549fbc52fd98c5ca3600092b",
			ReportPolicy.BATCH, "ios");

	MobClickGameAnalytics.pay(100, 1, 200);
	MobClickGameAnalytics.buy("xxoo", 1, 100);
	MobClickGameAnalytics.use("xxoo", 1, 100);

	MobClickGameAnalytics.startLevel("1");
	MobClickGameAnalytics.finishLevel("1");
	MobClickGameAnalytics.failLevel("1");

	final NSDictionary<NSString, NSString> dic = new NSDictionary<NSString, NSString>();
	dic.setAssociatedObject(new NSString("1"), new NSString("1"));
	dic.setAssociatedObject(new NSString("2"), new NSString("2"));

	MobClickSocialWeibo weibo = new MobClickSocialWeibo(MobClickSocialWeibo.MobClickSocialTypeSina(),
			"xxxxxxxooooo", "12345", dic);
	List<MobClickSocialWeibo> weibos = new ArrayList<MobClickSocialWeibo>();
	weibos.add(weibo);

	MobClickSocialAnalytics.postWeiboCounts(weibos,
			"549fbc52fd98c5ca3600092b", "测试", null);

	return super.didFinishLaunching(application, launchOptions);
}
 
开发者ID:tianqiujie,项目名称:robovm-ios-bindings,代码行数:30,代码来源:IOSLauncher.java


示例19: didFinishLaunching

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public boolean didFinishLaunching(UIApplication application,
		UIApplicationLaunchOptions launchOptions) {

	MobClick.startWithAppkey("your key", ReportPolicy.BATCH, "ios");

	MobClickGameAnalytics.pay(100, 1, 200);
	MobClickGameAnalytics.buy("xxoo", 1, 100);
	MobClickGameAnalytics.use("xxoo", 1, 100);

	MobClickGameAnalytics.startLevel("1");
	MobClickGameAnalytics.finishLevel("1");
	MobClickGameAnalytics.failLevel("1");

	final NSDictionary<NSString, NSString> dic = new NSDictionary<NSString, NSString>();
	dic.setAssociatedObject(new NSString("1"), new NSString("1"));
	dic.setAssociatedObject(new NSString("2"), new NSString("2"));

	MobClickSocialWeibo weibo = new MobClickSocialWeibo(
			MobClickSocialWeibo.MobClickSocialTypeSina(), "xxxxxxxooooo",
			"12345", dic);
	List<MobClickSocialWeibo> weibos = new ArrayList<MobClickSocialWeibo>();
	weibos.add(weibo);

	MobClickSocialAnalytics.postWeiboCounts(weibos, "your key", "测试", null);
	
	return super.didFinishLaunching(application, launchOptions);
}
 
开发者ID:tianqiujie,项目名称:robovm-ios-bindings,代码行数:29,代码来源:IOSLauncher.java


示例20: get

import org.robovm.apple.foundation.NSString; //导入依赖的package包/类
@Override
public Map<String, ?> get () {
	Map<String, Object> map = new HashMap<String, Object>();
	for (NSString key : nsDictionary.keySet()) {
		NSObject value = nsDictionary.get(key);
		map.put(key.toString(), value.toString());
	}
	return map;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:10,代码来源:IOSPreferences.java



注:本文中的org.robovm.apple.foundation.NSString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InternalCircuit类代码示例发布时间:2022-05-23
下一篇:
Java ServerPlayerPositionRotationPacket类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap