本文整理汇总了Java中org.robovm.apple.foundation.NSData.read方法的典型用法代码示例。如果您正苦于以下问题:Java NSData.read方法的具体用法?Java NSData.read怎么用?Java NSData.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.robovm.apple.foundation.NSData
的用法示例。
在下文中一共展示了NSData.read方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setContentOfCell
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
public static UITableViewCell setContentOfCell(String name, NSURL url, String adresse, String email) {
UITableViewCell cell = new UITableViewCell(new CGRect(0, 0, 300, 60));
UIImageView img = new UIImageView(new CGRect(20, 10, 70, 70));
NSData data = (NSData)NSData.read(url);
img.setImage(new UIImage(data));
cell.getContentView().addSubview(img);
UILabel label1 = new UILabel(new CGRect(100, 10, cell.getContentView().getFrame().getWidth(), 20));
label1.setText(name);
label1.setTextColor(UIColor.colorBrown());
cell.getContentView().addSubview(label1);
UILabel label2 = new UILabel(new CGRect(100, 35, cell.getContentView().getFrame().getWidth(), 20));
label2.setText(adresse);
cell.getContentView().addSubview(label2);
UILabel label3 = new UILabel(new CGRect(100, 55, cell.getContentView().getFrame().getWidth(), 20));
label3.setText(email);
cell.getContentView().addSubview(label3);
return cell;
}
示例2: displayMailComposerSheet
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
/**
* Displays an email composition interface inside the application. Populates
* all the Mail fields.
*/
private void displayMailComposerSheet() {
MFMailComposeViewController picker = new MFMailComposeViewController();
picker.setMailComposeDelegate(this);
picker.setSubject("Hello from California!");
// Set up recipients
picker.setToRecipients(Arrays.asList("[email protected]"));
picker.setCcRecipients(Arrays.asList("[email protected]", "[email protected]"));
picker.setBccRecipients(Arrays.asList("[email protected]"));
// Attach an image to the email
String path = NSBundle.getMainBundle().findResourcePath("rainy", "jpg");
NSData myData = NSData.read(new File(path));
picker.addAttachmentData(myData, "image/jpeg", "rainy");
// Fill out the email body text
String emailBody = "It is raining in sunny California!";
picker.setMessageBody(emailBody, false);
presentViewController(picker, true, null);
}
示例3: load
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
public static void load(File path, int bufferId) {
NSData data = null;
try {
// mmap (if possible) the audio file for efficient reading/uploading
data = NSData.read(path, RoboAssets.READ_OPTS);
load(data.asByteBuffer(), path.getName(), bufferId);
} catch (NSErrorException e) {
throw new RuntimeException(e.toString());
} finally {
// now dispose the mmap'd file to free up resources
if (data != null) {
data.dispose();
}
}
}
示例4: getXML
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
public Document getXML(NSURL url) throws IOException {
Document document = null;
NSData nsData = (NSData) cache.get(url.getAbsoluteString());
try {
if(nsData == null) { // trying to fetch (does not exist in cache)
nsData = NSData.read(url);
if(nsData == null) {
if(url.isFileURL())
throw new FileNotFoundException(url.getAbsoluteString());
} else {
cache.put(url.getAbsoluteString(), nsData);
}
}
if(nsData != null) {
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
byte[] bytes = nsData.getBytes();
if(bytes != null) {
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
DocumentBuilder db = dfactory.newDocumentBuilder();
InputSource inputSource = new InputSource(inputStream);
document = db.parse(inputSource);
}
}
} catch (SAXException | ParserConfigurationException e) {
e.printStackTrace();
}
return document;
}
示例5: getXML
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
public static Document getXML(NSURL url) throws IOException {
Document document = null;
NSData nsData = NSData.read(url);
if(nsData == null) {
if(url.isFileURL())
throw new FileNotFoundException(url.getAbsoluteString());
}
if(nsData != null) {
document = getXML(nsData);
}
return document;
}
示例6: setContentOfCell
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
public void setContentOfCell(UITableViewCell cell, String txt, NSURL url) {
UIImageView img = new UIImageView(new CGRect(25, 5, 80, 80));
NSData data = (NSData) NSData.read(url);
img.setImage(new UIImage(data));
cell.getContentView().addSubview(img);
UILabel label = new UILabel(new CGRect(120, 30, cell.getContentView()
.getFrame().getWidth(), 20));
label.setText(txt);
cell.getContentView().addSubview(label);
}
示例7: getImageData
import org.robovm.apple.foundation.NSData; //导入方法依赖的package包/类
private static NSArray<?> getImageData() {
if (imageData == null) {
String path = NSBundle.getMainBundle().findResourcePath("ImageData", "plist");
NSData plistData = NSData.read(new File(path));
try {
imageData = (NSArray<?>) NSPropertyListSerialization.getPropertyListFromData(plistData,
NSPropertyListMutabilityOptions.None);
} catch (NSErrorException e) {
System.err.println("Unable to read image data: " + e.getError());
}
}
return imageData;
}