如何从Cocoa Objective-C应用程序中找到Mac OS X的版本号(例如"10.6.7")?
我在我的iOS应用程序中使用以下代码来使用Instagram iPhone挂钩将照片发布到Instagram.我只希望"Open In ..."菜单中有Instagram应用程序,没有其他应用程序.但在我的情况下,Camera +也出现了.我怎么能限制在Instagram?
另外,我可以直接打开Instagram而不是显示Open In菜单吗?
NSURL *instagramURL = [NSURL URLWithString:@"instagram://app"];
if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
//imageToUpload is a file path with .ig file extension
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:imageToUpload]];
self.documentInteractionController.UTI = @"com.instagram.photo";
self.documentInteractionController.annotation = [NSDictionary dictionaryWithObject:@"my caption" forKey:@"InstagramCaption"];
[self.documentInteractionController presentOpenInMenuFromBarButtonItem:self.exportBarButtonItem animated:YES];
}
Run Code Online (Sandbox Code Playgroud) 我有一个GWT + AppEngine应用程序,可以让用户创建在线民意调查.我想让民意调查创作者从他的民意调查中选择各种主题.我们将保存投票创建者在服务器上选择的主题,并且每当投票受访者访问投票时,他将获得具有所选主题的问题.
我们的主题意味着一组4-5种颜色,我们将用它来设置民意调查页面的样式.我们的客户端应用程序是一个GWT应用程序,其样式在UiBinder模板元素中设置为内联,例如:
<ui:style>
.header {
background: color1;
padding: 6px 6px;
}
.anothercssclass {
background: color2;
padding: 6px 6px;
}
</ui:style>
Run Code Online (Sandbox Code Playgroud)
请建议我们如何设置服务器上保存的主题的color1和color2.请注意,这不是GWT模块主题问题.
我的应用程序中有一个按钮和一个NSTextView.我希望NSTextView在按下按钮时获得焦点.如果我然后通过键盘输入文本,它应该进入NSTextView.
我应该在按钮的动作方法中添加什么代码?
在我的Cocoa应用程序中,我想让用户在Lion上全屏显示应用程序.为此,我想添加以下内容:
if (check for lion or above) {
[mywindow setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
}
Run Code Online (Sandbox Code Playgroud)
我有条件地为Lion添加这个,因为NSWindowCollectionBehaviorFullScreenPrimary只能从10.7开始.狮子座以上检查的最佳方法是什么?
我知道沙盒是在Mac OS X Lion(10.7)中引入的,但临时异常授权,特别是com.apple.security.temporary-exception.files.home-relative-path.read-write,是在后来的10.7.x中引入的.更新.哪个10.7.x更新?
我有一个sanboxed mac app,com.apple.security.assets.pictures.read-write权利设置为YES.因此,我可以访问用户的实际/用户/用户名/图片目录.
我想以编程方式获取此目录的路径,我该怎么做?
我目前执行以下操作,但它会导致沙箱容器图片位置.
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPicturesDirectory, NSUserDomainMask, YES);
//this gets the pictures directory in sandbox container not the actual user Pictures directory
NSString *userPicturesPath = [paths objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud) 我试图在具有中心对齐的可可NSView中绘制带有新行(\n)的字符串.例如,如果我的字符串是:
NSString * str = @"this is a long line \n and \n this is also a long line";
Run Code Online (Sandbox Code Playgroud)
我希望这看起来像:
this is a long line
and
this is also a long line
Run Code Online (Sandbox Code Playgroud)
这是我在NSView drawRect方法中的代码:
NSMutableParagraphStyle * paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setAlignment:NSCenterTextAlignment];
NSDictionary * attributes = [NSDictionary dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName];
NSString * mystr = @"this is a long line \n and \n this is also a long line";
[mystr drawAtPoint:NSMakePoint(20, 20) withAttributes:attributes];
Run Code Online (Sandbox Code Playgroud)
它仍然以左对齐方式绘制文本.这段代码有什么问题?
在尝试使用元数据中设置的软件名称保存图像时,出现异常“指定的 BitmapEncoder 不支持全局元数据。”
我怎样才能做到这一点?
using (Stream stream = File.Create(@"D:\Yourfile.png"))
{
RenderTargetBitmap rtb = new RenderTargetBitmap(600, 400, 300, 300, PixelFormats.Pbgra32);
DrawingVisual dv = new DrawingVisual();
//draw on drawing visual
rtb.Render(dv);
BitmapEncoder encoder = null;
BitmapMetadata metadata = null;
encoder = new JpegBitmapEncoder();
((JpegBitmapEncoder)encoder).QualityLevel = 90;
metadata = new BitmapMetadata("jpg");
metadata.ApplicationName = "My Software Name";
encoder.Metadata = metadata;
BitmapFrame bitmapFrame = BitmapFrame.Create(rtb);
encoder.Frames.Add(bitmapFrame);
encoder.Save(stream);
}
Run Code Online (Sandbox Code Playgroud) 我有一个最初有1.0版本的iOS应用程序.然后我发布了更新版本2.0.
是否有可能在3.0更新中检查用户最初在1.0或2.0或3.0中安装应用程序的时间?
我不想使用首选项,因为如果用户删除应用程序然后安装,这将不起作用.
我的xib文件中有一个UISegmentedControl.它链接到xib文件中值更改事件的操作方法.
当我以编程方式设置selectedSegmentIndex的值时,将调用action方法
mysegmentedcontrol.selectedSegmentIndex = index
Run Code Online (Sandbox Code Playgroud)
我期待只有当用户通过触摸来更改控件时才会调用操作方法?
这仅适用于UISegmentedControl.
我在自定义FrameworkElement的OnRender方法中绘制图像。我也想绘制此图像的阴影。我需要在代码中执行此操作,并且我不想使用DropShadowBitmapEffect,因为它已过时。我该如何实现?
public class MyDrawingView : FrameworkElement
{
protected override void OnRender(System.Windows.Media.DrawingContext dc)
{
drawImagesOnDrawingContext(dc);
}
public RenderTargetBitmap getBitmap()
{
DrawingVisual dv = new DrawingVisual();
using (DrawingContext dcMine = dv.RenderOpen())
{
drawImagesOnDrawingContext(dcMine);
dcMine.Close();
}
RenderTargetBitmap rtb = new RenderTargetBitmap(200, 200, 96, 96, PixelFormats.Pbgra32);
rtb.Render(dv);
return rtb;
}
private void drawImagesOnDrawingContext(System.Windows.Media.DrawingContext dc)
{
//how to draw shadow on bi?
BitmapImage bi = new BitmapImage(new Uri(@"D:\mytemp\img1.jpg"));
dc.DrawImage(bi, new Rect(50, 50, 100, 100));
//how to draw shadow on bi1
BitmapImage bi1 = new BitmapImage(new …Run Code Online (Sandbox Code Playgroud) 我想在我的Cocoa mac应用程序中以简单的tile模式在NSView drawRect中绘制一个NSImage.一种方法是使用drawInRect编写一个循环来多次绘制此图像:fromRect:operation:fraction:
有更直接的方法吗?
macos ×7
objective-c ×7
cocoa ×5
ios ×3
.net ×2
c# ×2
cocoa-touch ×2
gwt ×1
instagram ×1
nstextview ×1
nsview ×1
osx-lion ×1
sandbox ×1
wpf ×1