我想为按钮实现手势识别器(滑动动作).问题是,按钮是以编程方式创建的,并且根据一些条件存在或不存在.所以,我不知道是否有按钮,或者有多少按钮.
我知道我需要这样的东西:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if (touch.view == aButtonView) {
//get the button's tag
}
}
Run Code Online (Sandbox Code Playgroud)
当然,当按下任何按钮视图时,if语句应该返回Yes ...
任何人都知道这个词aButtonView应该是什么?或者,如果它甚至可能?提前致谢.
iphone xcode objective-c gesture-recognition uigesturerecognizer
我正在尝试创建一个使用REST将数据传递给客户端的Web服务.我现在卡在2个问题上,一个在客户端,一个在服务器端.我一直在尝试很多东西,然后我就更加困难了.我希望你们中的任何人都可以帮助我.
我尝试通过浏览器和整个应用程序来接近Web服务.如果我直接URL到服务器,我收到以下错误消息:
SEVERE: A message body writer for Java class java.util.ArrayList, and Java type java.util.Collection<domain.Tweet>, and MIME media type text/plain was not found
SEVERE: The registered message body writers compatible with the MIME media type are:
text/plain ->
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ReaderProvider
*/* ->
com.sun.jersey.core.impl.provider.entity.FormProvider
com.sun.jersey.core.impl.provider.entity.MimeMultipartProvider
com.sun.jersey.core.impl.provider.entity.StringProvider
com.sun.jersey.core.impl.provider.entity.ByteArrayProvider
com.sun.jersey.core.impl.provider.entity.FileProvider
com.sun.jersey.core.impl.provider.entity.InputStreamProvider
com.sun.jersey.core.impl.provider.entity.DataSourceProvider
com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General
com.sun.jersey.core.impl.provider.entity.ReaderProvider
com.sun.jersey.core.impl.provider.entity.DocumentProvider
com.sun.jersey.core.impl.provider.entity.StreamingOutputProvider
com.sun.jersey.core.impl.provider.entity.SourceProvider$SourceWriter
com.sun.jersey.server.impl.template.ViewableMessageBodyWriter
com.sun.jersey.json.impl.provider.entity.JSONJAXBElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONArrayProvider$General
com.sun.jersey.json.impl.provider.entity.JSONObjectProvider$General
com.sun.jersey.json.impl.provider.entity.JSONWithPaddingProvider
com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General
com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$General
com.sun.jersey.json.impl.provider.entity.JSONListElementProvider$General
com.sun.jersey.json.impl.provider.entity.JacksonProviderProxy
com.sun.jersey.moxy.MoxyMessageBodyWorker
com.sun.jersey.moxy.MoxyListMessageBodyWorker
Run Code Online (Sandbox Code Playgroud)
如果我运行客户端应用程序,我收到以下错误消息:
Exception in thread "AWT-EventQueue-0" com.sun.jersey.api.client.UniformInterfaceException: GET http://localhost:8080/KwetterSOAP/resources/rest/user/Hans/tweets returned a response status of 500 …Run Code Online (Sandbox Code Playgroud) 我有一个WPF应用程序,我可以最小化托盘.当我正常点击它时,窗口再次显示.
现在我想知道如何创建一个简单的ContextMenu?
将ContextMenu要得到充满了的onclick将运行一个函数x选项.现在我只需要一个'Exit'项链接到'Exit_Click'方法.
我尝试过的是:
ContextMenu menu = (ContextMenu)this.FindResource("NotifierContextMenu");
menu.IsOpen = true;
Run Code Online (Sandbox Code Playgroud)
menu不知道任何IsOpen价值.
其他例子喜欢使用很多不同的东西.其中一个要求我出于某种原因创建HostManager.
我只需要一个简单的ContextMenu.我怎样才能做到这一点?
我已经创建了一个WPF UI.以下代码存在于MainWindow.xaml.cs:
namespace AWPFProject
{
public partial class MainWindow : Window
{
private readonly ServiceLogic serviceLogic;
public MainWindow()
{
InitializeComponent();
serviceLogic = new ServiceLogic ();
}
}
}
Run Code Online (Sandbox Code Playgroud)
Servicelogic是我的中心阶层.从那里,调用方法或类来处理数据库管理之类的东西.
现在,该ServiceLogic类具有我想要绑定的值.例如,我有一个组合框,我可以向我的用户展示.XAML看起来像这样:
<ListBox Height="100" HorizontalAlignment="Left" Margin="6,44,0,0"
Name="listBox_detected" VerticalAlignment="Top" Width="120"
ItemsSource="{Binding Path=ServiceLogic.Users}" />
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,列表仍然是emtpy.我还需要做些什么才能在我的列表中获取这些信息?
嘿伙计们,我知道它经常被问到,但他们问题的答案似乎并不适用于此.
我的didFinishPickingMediaWithInfo方法没有被调用:(
这是我的代码:
.h文件:
#import <UIKit/UIKit.h>
@interface DevicePictureController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate> {
UIImageView *photo;
UIButton *selectPhoto;
UIButton *takePhoto;
NSMutableDictionary *listLocations;
NSMutableDictionary *listDevices;
UIImagePickerController *picker;
}
@property (nonatomic, retain) IBOutlet UIImageView *photo;
@property (nonatomic, retain) IBOutlet UIButton *selectPhoto;
@property (nonatomic, retain) IBOutlet UIButton *takePhoto;
@property (nonatomic, retain) UIImagePickerController *picker;
-(IBAction)selectPicture:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)
.m文件:#import"DevicePictureController.h"
@implementation DevicePictureController
@synthesize photo, selectPhoto, takePhoto, picker;
- (void)viewDidLoad
{
[super viewDidLoad];
listLocations = [[NSMutableDictionary alloc] init];
listDevices = [[NSMutableDictionary alloc] init];
picker = [[UIImagePickerController alloc] init];
} …Run Code Online (Sandbox Code Playgroud) 我正在使用tableview,我想要行数(即tableview中的项目数).如果可用,我如何获得行数?
请帮助我,提前谢谢.
如何以及在何处创建一个样式,为所有按钮控件提供资源蓝色(黄色边框,蓝色背景)?
它也可以添加到texbox吗?
是否有一个集中的地方,因为我希望这种风格能够影响我的应用程序中不同页面中的按钮?
我有一个问题:我有一个NSMutableArray,我在多个视图中传递.在其中一个视图中,可以编辑该数组(NSMutableDictionary)中的对象的值.我这样做使用代码:
NSMutableDictionary *tester = [[NSMutableDictionary alloc] initWithDictionary:selectedItem copyItems:YES];
NSMutableString *newLoc = [[NSMutableString alloc] initWithString:locationField.text];
[tester setValue:newLoc forKey:@"Location"];
[selectedList replaceObjectAtIndex:[selectedList indexOfObject:selectedItem] withObject:tester];
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是在selectedList中替换该对象.它给出了错误*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI replaceObjectAtIndex:withObject:]: unrecognized selector sent to instance 0xa631e30'
它是有效的,如果我复制selectedList的副本数组中的新项目,并再次使用新值分配selectedList,但其他视图有问题在数组中再次找到相同的列表(新分配的位置).
TL; DR版本:如何编辑NSMutableArray中的值(通过替换?)?为什么不替换ObjectAtIndex工作?
编辑:确实是不可改变的.不过,主要问题仍然是:我有:
NSMutableDictionary *tester = [[NSMutableDictionary alloc] initWithDictionary:geselecteerdItem copyItems:YES];
[geselecteerdItem setValue:nieuweLoc forKey:@"Location"];
[geselecteerdeLijst replaceObjectAtIndex:[geselecteerdeLijst indexOfObject:tester] withObject:geselecteerdItem];
Run Code Online (Sandbox Code Playgroud)
当我使用:时[warningList replaceObjectAtIndex:[warningList indexOfObject:geselecteerdeLijst] withObject:keuzeLijst],它给了我一个outofbounds错误,因为geselecteerdeLijst数组的索引在warningList中明显改变了.有任何想法吗?
我正在尝试在我的应用中打开.pdf文件.我修改了Info.plist,以便在我的应用程序中打开.pdf.
我使用以下代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
thePDFurl = (NSURL *)[launchOptions valueForKey:UIApplicationLaunchOptionsURLKey];
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在另一个类中,我的appDelegate(包含那个didFinishLaunchingWithOptions),我有了这条线:
appDel = [[UIApplication sharedApplication]delegate];
[theLabel setText:[NSString stringWithFormat:@"%@", appDel.thePDFurl]];
Run Code Online (Sandbox Code Playgroud)
不知何故,theLabel总是显示(null).我错过了什么?
我在这个程序中得到了一个例外.我试图做一些改变,但它仍然无法正常工作.我试图将数据从demo.txt写入demo1.txt,但它给出了一个NullPointerException.我在这做错了什么?
import java.io.*;
class CopyFile{
public static void main(String[] args){
String str = null ;
try {
File f = new File("/home/newlabuser/workspace/CopyFileDemo/src/demo.txt");
if(f.exists())
{
if(f.canRead())
{
FileInputStream fin = new FileInputStream(f);
BufferedInputStream bin = new BufferedInputStream(fin);
DataInputStream din = new DataInputStream(bin);
while((str=din.readLine())!=null)
System.out.println(str);
writeTextFile("/home/newlabuser/workspace/CopyFileDemo/src/demo1.txt",str);
din.close();
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
public static void writeTextFile(String fileName, String s) {
FileWriter output;
try {
output = new FileWriter("/home/newlabuser/workspace/CopyFileDemo/src/demo1.txt");
BufferedWriter writer = new BufferedWriter(output);
writer.write(s);
writer.close(); …Run Code Online (Sandbox Code Playgroud) iphone ×5
objective-c ×5
c# ×3
xcode ×3
java ×2
wpf ×2
arrays ×1
camera ×1
contextmenu ×1
dictionary ×1
glassfish-3 ×1
ios ×1
ios4 ×1
netbeans ×1
rest ×1
tray ×1
uitableview ×1
web-services ×1
xaml ×1
xcode4 ×1