我正在尝试在Rails 4中构建一个联系表单,其中表单采用名称,电子邮件和正文,并将其发送到我的电子邮件地址.单击"提交"后,应用程序会正确地重定向回"联系人"页面,但似乎没有电子邮件发送.
match '/send_mail', to: 'contact#send_mail', via: 'post'
Run Code Online (Sandbox Code Playgroud)
<!DOCTYPE html>
<html>
<head>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<p>You have received the following email from <%= "#{ @name } (#{ @email }):" %></p>
<p><%= @body %></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
def send_mail
name = params[:name]
email = params[:email]
body = params[:comments]
ContactMailer.contact_email(name, email, body).deliver
redirect_to contact_path, notice: 'Message sent'
end
Run Code Online (Sandbox Code Playgroud)
class ContactMailer …Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails actionmailer contact-form ruby-on-rails-4
这个问题让我抓狂.我正在尝试更改viewController用户更改分段控件的选定"选项卡"的时间.我花了几个小时进行研究,但却找不到一个有效或通过故事板完成的答案.
它真的很烦我,因为设置标签应用程序是如此简单,但尝试使用像标签应用程序一样的分段控件是行不通的.我已经知道如何检测分段控件中选择的索引.我怎样才能做到这一点?
非常感谢你.
我有一个UIView子类,它将是一个工具提示,可以出现在任何视图控制器的底部,以显示提示/错误消息/成功消息/等.工具提示视图有两个子视图:UILabel左侧和UIView右侧,可以是任何内容(但通常用作a UIButton).
TooltipView.h
@interface TooltipView : UIView
@property (nonatomic, readonly) UILabel *textLabel;
@property (nonatomic) UIView *rightView;
Run Code Online (Sandbox Code Playgroud)
TooltipView.m
static CGFloat const kSubviewToSuperviewSpacing = 7.0f;
static CGFloat const kTextLabelToRightViewHorizontalSpacing = 7.0f;
@implementation TooltipView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
_textLabel = [[UILabel alloc] init];
_textLabel.numberOfLines = 0;
[_textLabel setTranslatesAutoresizingMaskIntoConstraints:NO];
[self addSubview:_textLabel];
}
return self;
}
- (void)setRightView:(UIView *)rightView {
if (_rightView != rightView) {
_rightView = rightView;
[self addSubview:_rightView];
[self setNeedsDisplay]; …Run Code Online (Sandbox Code Playgroud) 我有几个已经在我的项目中成功使用的私有 Pod。我在工作区(而不是项目)中添加了一个 Swift 游乐场,并import Foo在游乐场的顶部添加了一条语句。
自动完成功能适用于我的 pod 模块,因此似乎设置正确。但是,我收到了这个非常模糊的错误:
expression failed to parse, fixed expression suggested:
#sourceLocation(file: "Foo.playground", line: 1)
Run Code Online (Sandbox Code Playgroud)
我把导入语句放在哪一行都没有关系;它总是指第 1 行。
正在导入的框架中特别有一些 Obj-C 代码。我不确定这是否重要,因为它可以从我的应用程序中的 Swift 调用。
任何帮助,将不胜感激!
更新(2019 年 7 月 21 日):仍然无法解决这个问题,但我能够确认一个更简单的 Obj-C 库可以从操场调用。所以,这只是我最初尝试调用的复杂方法。由于这是专有的,我可以分享的信息并不多,但是如果有人对尝试什么(或我可以在此处进行泛化、提取和分享的内容)有任何建议,我很乐意尝试并更新你。谢谢!
我正在通过Uber API提出乘车请求.我成功发出请求并获得处于处理状态的响应.然后我打开我的优步应用程序观看,直到它进入接受状态,但它永远不会到达那里.经过大约15秒的处理后,它弹出一个奇怪的错误信息,这是我在Uber应用程序中从未见过的:"所有车辆目前都在使用.请致电(206)622-6500".我打电话给电话号码只是为了看,这是西雅图黄色出租车的号码.
我尝试使用优步应用程序正常发出请求,它工作正常.
我没有使用API沙箱制作我的乘车请求; 我实际上正在尝试使用我个人帐户的有限访问请求范围为自己请求.
由于我正在成功提出请求,因此没有任何代码可以与此关联.Uber API支持要求我在StackOverflow上提出问题,而不是直接与他们联系.
我已UISearchDisplayController正确连接到UITableViewIB 中的自定义标题.但是,当我搜索任何内容时,searchResultsTableView只显示"无结果",而我似乎无法找到代码不正确的位置.
searchResults 属性
- (NSMutableArray *)searchResults {
if (!_searchResults) {
_searchResults = [[NSMutableArray alloc] initWithCapacity:self.listingPreviews.count];
}
return _searchResults;
}
Run Code Online (Sandbox Code Playgroud)
表视图数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
NSInteger numberOfRows = 0;
if (tableView == self.tableView) {
numberOfRows = self.listingPreviews.count;
} else {
numberOfRows = self.searchResults.count;
}
return numberOfRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Listing";
ListingPreviewTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; …Run Code Online (Sandbox Code Playgroud) search objective-c uitableview uisearchdisplaycontroller ios
我有一个自定义静态UITableViewCell,我希望看起来与右侧细节单元格完全相同(UILabel在左侧,UILabel右侧),除了我希望右边UILabel是可编辑的UITextField.由于我想在故事板中的多个视图控制器中使用此单元,我决定最好的选择是创建一个MyEditableTableViewCell.xib文件,以及相应的*.h,m文件.我在MyEditableTableViewCell.h中有两个公共属性:
@property (weak, nonatomic) IBOutlet UILabel *textLabel;
@property (weak, nonatomic) IBOutlet UITextField *detailTextField;
Run Code Online (Sandbox Code Playgroud)
这些IBOutlets的连接UILabel,并UITextField在文件的.xib.在我的故事板中,我有一个自定义UITableViewController子类,我将所需的类更改UITableViewCell为MyEditableTableViewCell.我的视图控制器中有一个属性:
@property (weak, nonatomic) IBOutlet MyEditableTableViewCell *myCell;
但是,当我运行应用程序时,单元格显示为一个空白单元格.对它运行一些检查,我看到[myCell isKindOfClass:[MyEditableTableViewCell class]]返回true.但是,UITextField似乎永远不会得到实例化.当我试图改变时myCell.detailTextField.text,没有任何反应,myCell.detailTextField似乎是零.
任何帮助,将不胜感激!
我正在尝试使用AFNetworking向服务器发送POST请求,一切似乎都在工作,即应用程序成功ping服务器.但是,当它到达服务器时,它发送的参数值是空白的,即使在使用调试器单步执行下面的代码之后,值似乎正在成功传递.任何有关这方面的帮助将不胜感激.
APIClient.m
#import "APIClient.h"
#import "AFJSONRequestOperation.h"
// Removed URL for privacy purposes.
static NSString * const kAPIBaseURLString = @"string goes here";
@implementation APIClient
+ (APIClient *)sharedClient {
static APIClient *_sharedClient;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[APIClient alloc] initWithBaseURL:[NSURL URLWithString:kAPIBaseURLString]];
});
return _sharedClient;
}
- (id)initWithBaseURL:(NSURL *)url {
self = [super initWithBaseURL:url];
if (self) {
[self registerHTTPOperationClass:[AFJSONRequestOperation class]];
// Accept HTTP Header; see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1
[self setDefaultHeader:@"Accept" value:@"application/json"];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
LoginBrain.m中的登录方法
- (void)loginUsingEmail:(NSString *)email andPassword:(NSString *)password withBlock:(void …Run Code Online (Sandbox Code Playgroud) 我想补充一个cameraOverlayView上一个UIImagePickerController,但我想覆盖到覆盖显示了将被相机捕捉,而不是"取消"按钮在屏幕的只是一部分,拍照按钮,闪光灯设置,或类似的东西.如何动态确定UIImageView叠加层的帧应该是什么?
我附上了一张图片来说明我正在讨论的部分.

objective-c uiimageview uiimagepickercontroller ios camera-overlay
我想读一个bash脚本混帐配置价值,取决于它是否是有条件地作用于它true或false。
我希望能够做到:
if [ $(git config --get myvalue) ]; then
echo "True"
else
echo "False"
fi
Run Code Online (Sandbox Code Playgroud)
然而,当我运行上面的例子,True是始终打印。直接比较值true似乎可以正常工作,如下所示:
if [ $(git config --get myvalue) = true ]; then
echo "True"
else
echo "False"
fi
Run Code Online (Sandbox Code Playgroud)
但是,大多数编程语言不需要与布尔值进行直接比较,因此这与我的预期背道而驰。
它实际上看起来像这样有效:
if $(git config --get myvalue); then
echo "True"
else
echo "False"
fi
Run Code Online (Sandbox Code Playgroud)
我的理解是,将表达式放入[ ]调用test引擎盖下的命令。但是,我不清楚为什么布尔表达式不能用test.
为什么不能[ ]正确评估表达式?
ios ×6
objective-c ×4
uitableview ×2
actionmailer ×1
afnetworking ×1
autolayout ×1
bash ×1
cocoapods ×1
contact-form ×1
custom-cell ×1
git ×1
post ×1
ruby ×1
search ×1
storyboard ×1
swift ×1
uber-api ×1
uiimageview ×1
uistoryboard ×1
uiview ×1
xib ×1